1. Introduction
The erratic existence of prime number gaps has mesmerized
mathematicians and enthusiasts alike for centuries. Going back as early
as the late 18^{th} century, eminent mathematicians have made numerous attempts to formulate a prime counting function P(N), such as Gauss’s early approximation of.
Currently, we speak of the prime number theorem, which
suggests an asymptotic form for the number of primes less than some
integer. However, the formulaic representation of the prime number theorem remains one of the largest open problems in the world of mathematics.
Whilst investigating the distribution of primes, one would of course
compile the number of primes less than a certain given list of integers,
and, amid the N vs. P(N) observations,
one should arrive at an approximation formula. During Gauss’s later
investigations, he noticed that the density of primes in a chiliad
decreased approximately as, in turn leading Gauss to revise earlier
approximations, e.g.,
For the methods of correlation of N
$N$
vs. P(N
$P(N$
),
perhaps the most discussed conjecture is the Riemann hypothesis.
Proposed by Bernhard Riemann in 1859,the Riemann hypothesis is a
conjecture that suggests the nontrivial zeros of the Riemann zeta function all have real part 1/2.However, we shall not refer to or quote the Riemann hypothesis any further in this paper.
Albeit, no single function or formulae that correctly evaluates P(N
$P(N$
) for all N<∞
$N<\infty $
appears to exist. Furthermore, the ever growing approximations and
emerging hypotheses pertaining to the prime number theorem seem to be
unprovable.
At this point, we will describe the situation as that of a ‘headache’ and consider our options for dealing with it.
In modern day analyses, given the vastly increased computing efficacy on hand, we study larger N
$N$
,
and this usually leads us to modify the Gaussian formulation and/or
other similar prime density functions. That is to say, we do our share
of the ‘aspirin’ approach. Nonetheless, the headache remains. In this paper, we are, however, free to invent, and we can stop the ‘aspirin’
approach; we abstain from antiquated approaches, such as basic
interpolations of Gauss, Legendre, Riemann and others, and can start
afresh.
Consequently, noteworthy results follow. We see that a prime number distribution sequence exists and computes the exact count of prime numbers less than and equal to all integers N
$N$
, for all N<∞,
$N<\infty ,$
making it possibly the first and only ever formulation for the P(N
$P(N$
) calculation. Furthermore, in contrast to the complex variable Riemann zeta function, which is a convergent infinite series, the computations for the prime counting function P(N
$P(N$
)formulated here require fewer than N
$N$
steps yet provide accurate results.
In general, the reader will be confronted with questions. Should we
have expected an order in the prime numbers or a single analytical
function to return true P(N
) values? Also, why is it that a problem description simply defined as the prime number theorem finds its way into complex variable analysis, such as the Riemann zeta function?
The analysis presented here will be new to hardened analysts familiar
with the Gaussian or Riemann zeta function formulations that have
dominated the history of this problem. With this in consideration, we
will be tackling the original approach presented in this paper in its
simplest terms.
We will go on to show that the distribution of prime numbers may be
best visualized in twodimensional space. Additionally, it is perhaps
here where we can draw the most resemblance between our analysis and the
Riemann complex plane analysis.
We will create some controversy. We question whether the number 2 is
really a prime number. However, we will make it easier for those who
prefer to verify the equations by means of coding, and thus we provide a
set of source code at the end of the paper.
We will conclude this paper with a decisive test for determining whether infinitely many twin primes exist.
2. Counting prime numbers less than a positive integer N > 1
Consider computing the count of all prime numbers, less than and including some input integer, N
$N$
, that is greater than 1
$1$
. We ignore divide and count
testing, computational memory sieving solutions or other approximation
techniques within our analysis. Suppose, however, that we invent a
simplified prime number model whereby we replace the division by divisors model that applies to all integers less than some given N
and that we limit the division to 2 only. Thus, under this proposition, the whole number 9
$9$
, for instance, where N≥9
$N\ge 9$
, can be classified as a prime number and counted for P
$P$
.
Let us examine this further with an example. If we have some input integer N
$N$
, say, 10
$10$
, then the prime count will be 5
$5$
, i.e., including the integer 1
$1$
, our primes are 1
$1$
, 3
$3$
, 5
$5$
, 7
$7$
and 9
$9$
. Similarly, if the input N
$N$
is 9
$9$
, then there will again be the same 5
$5$
prime numbers.
Therefore, we can deduce a formula for the prime counting function P, where our simplified model applies and the input integer is greater than1
$1$
, as follows,
where,
P
$P$
is the count of primes; the subscript 2
$2$
denotes the division limit is imposed as 2
$2$
,
[]
$[]$
is the floor operation,
and R
$R$
is the residue equal either to 0
$0$
or 1
$1$
as determined by,
R=0
$R=0$
if ((N/2
$((N/2$
 [N / 2]) = 0) or R=1
$R=1$
if ((N/2
$((N/2$
 [N / 2]) > 0).
Therefore, we prove that we can simply compute the count of primes by means of a prime counting function and we can further our technique. However, before we do so, we shall revisit the definition of prime numbers.
3. Vigorous definition of prime numbers
The conventional definition of a prime number, or simply a prime, is given as “a positive integer greater than 1 that has no positive divisors other than 1 and itself“. This definition, therefore, explicitly excludes 1
$1$
as being the lower boundary of the prime number test. The equation for P2
$P2$
provided by equation [1] should therefore take this omission into account, giving,
Consequently, P2(N
$P2(N$
) will be equal to 4
$4$
, as willP29
$P29$
, now yielding the primes 3
$3$
, 5
$5$
, 7
$7$
and 9
$9$
.
We know that the natural number 2
$2$
is universally accepted to be a prime number. Let us, however, reestablish whether two is a prime number. On this occasion, we can safely use equation [2] when evaluating P(2
$P(2$
).
Following from the conventional definition of primes, 2
$2$
is greater than 1
$1$
, making it eligible for prime testing. However, 2
$2$
cannot be dividetested by 2
$2$
, as it is equal to itself, i.e., it is the upper boundary of the prime number test. Therefore, when the divisors 1
$1$
and 2
$2$
are taken away from the prime testing of the value 2,
$2,$
we are not left with any other whole number to subject 2
$2$
to for any specific prime testing. Therefore, one point of argument can be that 2
$2$
is not a prime number because, by definition, it has removed itself from the analysis altogether.
Let us look at an alternative argument by considering the modified P2(N
$P2(N$
) in equation [2]; when we input the integer 2
$2$
, we obtain the following result,
Therefore, the output of equation [3] suggests that there are no primes between 1
$1$
and 2
$2$
inclusive. Therefore, it may be claimed that 2
$2$
is not a prime number and that there are no primes less than and including 2
$2$
.
Whilst the basis for rejecting the whole number 2
$2$
as a prime number is compelling enough, in this paper, however, overall P
$P$
values will count the integer 2
$2$
as a prime number for the sake of historical conformity. Furthermore, except where stated otherwise, in the computation of the P
$P$
value for a given natural number N
$N$
, N
$N$
will also be subjected to prime testing and factored to P
$P$
value provided that N
$N$
itself is a prime number.
4. Extension of the basic P_{2 }formula
We shall now show that the P2
$P2$
formulation given by equation [2] can be extended to larger integers,
consequently leading to the derivation of an orderly series that allows
us to compute precise P(N
) values for all input N
$N$
→∞.
We advance our analysis with the extension of division to the divisor 3in the simplified prime number analysis introduced earlier. Now, let us examine the impact the divisors 2
$2$
and 3
$3$
have on the count of P
$P$
. We can call the new P
$P$
value P2,3
$P2,3$
and seek to evaluate by formulating as before.
When we prime tested integers less than some given N
$N$
in accordance with our simplified (P_{2}) model, it was obvious that, starting with 3
$3$
, every alternating number was a prime number,
2  3  4  5  6  7  8  9  10  11  12… 
2  2  2  2  2  2… 
As we evolve our prime number analysis to (P_{2, 3}), we now have,
2  3  4  5  6  7  8  9  10  11  12… 
2  3  2  2  2  3  2  2… 
We note that one of the important consequences of this new arrangement is that every alternating 3
$3$
will now be masked by the smaller integer division, in this case 2
$2$
.
Accordingly, every (4^{th}) and (2^{nd})gap between 2
$2$
‘s (in the bottom rows of the above sets)is now a prime number. Let us rename these gaps between 2
$2$
‘s as voids and call this arrangement a 4–2 system.
An equation for the above 4–2system can be conveniently formulated, and a particular solution is given here as,
Where A
$A$
, B
$B$
and C
$C$
are constants that take the values A=−1,0,1
$A=1,0,1$
; B=0,1
$B=0,1$
and C=0,1
$C=0,1$
to provide for the integer solution to (P_{2, 3}), and where 2
$2$
<N<∞
$N<\infty $
. Note that the (P_{2, 3})
equation may be reformulated in different ways or by using
trigonometric functions without any loss of generality. The addition of +1
accounts for the prime number 2
$2$
.
The (P_{2, 3}) equation may be
computed by means of software coding. We provide the source code for
equation [4] in section 10.1 for testing purposes.
In the below table, we tabulate the P(N
$P(N$
)values for 2 <N<25
$N<25$
using equation [4].
N
$N$

P(N
$P(N$
) 
3  2 
4  2 
5  3 
6  3 
7  4 
8  4 
9  4 
10  4 
N
$N$

P(N
$P(N$
) 
11  5 
12  5 
13  6 
14  6 
15  6 
16  6 
17  7 
18  7 
N
$N$

P(N
$P(N$
) 
19  8 
20  8 
21  8 
22  8 
23  9 
24  9 
We incidentally showed that (P_{2, 3 }) given by equation [4] calculates the exact count of prime numbers for any given positive integer 2<N<25
$2<N<25$
. As expected, the P(N
$P(N$
) values in the above table also reflect the order of the 4–2
$4\u20132$
system. The (P_{2, 3}) succeeds because all values of N
$N$
less than 25
$25$
have divisors of 2
$2$
or 3
$3$
; otherwise, they happen to be prime numbers. This, however, first changes when N=25
$N=25$
, where the smallest divisor is no longer 2
$2$
or 3
$3$
.
Inevitably, the discussed methodology may be extended to the formulation of P(N
$P(N$
) for larger integers. However, as N
$N$
, the onset of new integers that can remove the potential primes from their residing voids and the possible masking by smaller divisors makes the formulation of P(N
$P(N$
) increasingly cumbersome. It is worth pointing out now that this convoluted yet systematic removal/masking process is what shapes or distorts the count of primes, providing its erratic appearance.
It is reasonable to assume that there should not be any basis for a
single analytic function, complex variable or not, to represent exact
values of P(N
) because the underlying principle of P(N
$P(N$
) can be regarded as a step change process.
Let us explain this with an example. We know that (P(10^{6}) = 78,498), (P(10^{7}) = 664,579), (P(10^{8})
= 5,761,455), etc. In addition, the largest prime, (L), for (N = 1000
is 997). Let us assume that there are no other primes in existence that
are larger than (L). Then, the (P(N)) values would change to (P(10^{6}) = 120,784), (P(10^{7}) = 1,203,466 )and (P(10^{8}) = 12,029,477). The new (P(N)) values clearly show that a more behaved relationship now exists.
The order of the prime numbers is therefore in the destruction rather than in the creation, and because the underlying operation belongs to an elimination process, we now attempt to formulate the order of the elimination process and show that the residual, i.e., what now becomes the prime numbers, provides an accurate calculation of P(N
$P(N$
). We do this next.
5. Overall prime number order and prime number distribution sequence
For reasons that will become apparent later in the paper, we will continue to extend our analysis on the aforesaid 4–2
$4\u20132$
system. However, the reader should note that the results that follow can be obtained in the absence of the 4–2
$4\u20132$
system, for example, by means of similar inference.
We noted that the divisors 2
$2$
and 3
$3$
result in the four integer solutions of equation [4] during our P(N
$P(N$
) calculations. As discussed earlier, the constants of equation [4] take the following values: A=0
$A=0$
; A=−1
$A=1$
and B=0
$B=0$
; or A=1
$A=1$
,B=1
$B=1$
and C=0
$C=0$
or 1
$1$
.
We will again look for four integer solutions, which we will represent by (S_{n}) and where n=1
$n=1$
, 2
$2$
, 3
$3$
and 4
$4$
, such that every S
$S$
is a product of two base prime numbers S_{n} = S_{x}× S_{Y}, and show that a set of four second order sequences,( P_{n}), exists and that each (P_{n}) has a starting point of (S_{n })with higher terms derived by simple (S_{n })relationships. Furthermore, the terms of the (P_{n}) sequence will solely occupy the voids of the 4–2
$4\u20132$
system for all N<∞
$N<\infty $
.
Previously, we noted that (S_{1}) is equal to 25
$25$
, which, as we know, is a product of two prime numbers, so that( S_{n} = S_{x} × S_{Y }= 5 × 5). We therefore know that our first series(P_{1}) will be based on multiples of the smallest divisor of( S_{1}).
Accordingly, by way of interpolation and using an extension for equation [4], we can formulate the following series,
where,
(S_{x })and( S_{Y}) are base primes,
i, j = 0, 1, 2…,
D
$D$
is a constant equal to either 0
$0$
or 1
$1$
providing for integer solutions to (_{n}),
E
$E$
is a constant equal to +/−1
$+/1$
(positive for P_{1} and P_{2 }and negative for P_{3} and P_{4}).
By way of a similar correlation, we obtain the remaining three prime base
sets as (5 × 7), (7 × 7) and (7 × 11). (Note that, in the source code
provided in section 10.3, the base prime values are quoted as (2 + 3, 2 +
3), (2 + 3, (2 × 2) + 3), ((2 × 2) + 3, (2 × 2) + 3) and ((2 × 2) + 3,
(3 × 3) + 2) to reflectthe (P_{2, 3}) dependency, which the reader can easily verify).
The first few values of P′n
$Pn\prime $
for each of the base primes is tabulated below, where columns correspond to i
$i$
terms and rows j
$j$
terms,
9  19  29  39  49  59  69  79  89 
41  63  85  107  129  151  173  195  
97  131  165  199  233  267  301  
177  223  269  315  361  407  
281  339  397  455  513  
409  479  549  619  
561  643  725  
737  831  
937 
12  22  32  42  52  62  72  82  92 
48  70  92  114  136  158  180  202  
108  142  176  210  244  278  312  
192  238  284  330  376  422  
300  358  416  376  422  
432  502  572  642  
588  670  752  
768  862  
972 
17  31  45  59  73  87  101  115  129 
57  83  109  135  161  187  213  239  
121  159  197  235  273  311  349  
209  259  309  359  409  459  
321  383  445  507  569  
457  531  605  679  
617  703  789  
801  899  
1009 
26  40  54  68  82  96  110  124  184 
74  100  126  152  178  204  230  256  
146  184  222  260  298  336  374  
242  292  342  392  442  492  
362  424  486  548  610  
506  580  654  728  
674  760  846  
866  964  
1082 
Substituting the above (P’_n values into equation [5], we evaluate the boundary values of all prime numbers as N→∞
$N\to \infty $
at least once.
To compute P(N
$P(N$
), we count the terms of the sequence (P_{n}) provided that its value is less than N
$N$
, followed by subtracting the total sum, T
$T$
, from the (P_{2, 3}) value calculated using equation [4], as follows,
We can combine the set of (P_{n}) series and arrive at the prime number distribution sequence previously selfpublished on the Nuclear Strategy, Inc. webpage,
where,
i=0,1
$i=0,1$
,
j=2,3,4…
$j=2,3,4\dots $
and,
Equation [8] is a simplified version of equation [6] for programming
convenience. The source code that implements equation [8] is provided in
section 10.2 (applicable for N<175
). Once again, we apply equation [5] and [7] to compute P(N
$P(N$
) for all N→∞
$N\to \infty $
.
Note that, in the source code of section 10.3, the reader can see that the total element count T
$T$
of elements of (_{n })for which the element value is less than (P_{2, 3 })is calculated first and then subtracted from (P_{2, 3}). This effectively eliminates the implementation of equation [5] in our code because equation [5] is in fact the inverse of (P_{2, 3}). In both cases, as expected, the value of the total sum T
$T$
will be the same.
Equation [8] may also be written in various ways. However, equation [6] remains the crux of the prime number origin and, accordingly, the prime number distribution sequence is the function that forms the relationship between values that measure the disorder in prime numbers.
Finally, we tabulate the P(N
$P(N$
)values for 24 <N<175
$N<175$
using equation [7] and discuss its limitations in the next section,
N
$N$

P(N
$P(N$
) 
25  9 
26  9 
27  9 
28  9 
29  10 
30  10 
31  11 
32  11 
33  11 
N
$N$

P(N
$P(N$
) 
34  11 
35  11 
36  11 
37  12 
…  … 
162  37 
163  38 
164  38 
165  38 
N
$N$

P(N
$P(N$
) 
166  38 
167  39 
168  39 
169  39 
170  39 
171  39 
172  39 
173  40 
174  40 
The reader can verify the results provided in the above table by
experimenting with the source code of equations [7] and [8],which is
provided in sections 10.2 and 10.3.
6. Limitations of the prime number distribution sequence
When we substitute i=0,j=2
$i=0,j=2$
and k=5
$k=5$
into equation [8], we obtain 59
$59$
. Similarly, when we substitute i=1,j=2
$i=1,j=2$
and k=3
$k=3$
into equation [8], we again obtain 59
$59$
. This implies that the terms of the sequence will produce repeated roots. This is because of the way terms of the P′n
$Pn\prime $
series intertwine. Accordingly, equation [5] of the prime number distribution sequence can
only provide accurate results if multiple counting of equal terms is
averted. The first such instance of repeated roots occurs when N=175
.
Fortunately, there are a number of methods for managing the prime number distribution sequence effectively.
As the repeated roots exist in orderly fashion, one apparent approach
to prevent double counting is by forcing parameter increment thresholds.
Alternatively, we can simply allow multiple counting and correct the
resultant P(N
) by subtracting the repeat sequence values. A restricted parameter increment technique is used in the source code provided in section 10.3.
We obtain the results below using the prime number distribution sequence using the source code provided in section 10.3,
N
$N$

P(N
$P(N$
) 
10^{1}  4 
10^{2}  25 
10^{3}  168 
10^{4}  1229 
10^{5}  9592 
10^{6}  78498 
10^{7}  664579 
10^{8}  5761455 
10^{9}  50847534 
7. Effective use of the prime number distribution sequence
By variation of the parameters of the prime number distribution sequence, we observe that, as we increment through j
$j$
at constant i
$i$
, the terms of the Pn
$Pn$
series approach N
$N$
more rapidly than incrementing through i
$i$
at constant j
$j$
. For example, given P′1
$P1\prime $
, when i=8
$i=8$
and j=0
$j=0$
, the result is P′1=89
$P1\prime =89$
; however, when i=0
$i=0$
and j=8
$j=8$
, P′1=937
$P1\prime =937$
; see section 5. Furthermore, for small j
$j$
, the problem of repeated terms of the prime number distribution sequence is less prevalent. Therefore, we can implement a technique called block counting, defined as follows: block counting enables us to omit the counting of the terms of the prime number distribution sequence, replacing it with the formulaic evaluation of the entire size of a row at a particular j
$j$
. This works effectively for small j
$j$
and eliminates i
$i$
computations altogether. However, as j
$j$
increases, efficient methods for the first integer solution of the Diophantine equation and combinatory mathematics begin to dominate our analysis.
However, as expected, the most significant advantage of block counting that cannot be overlooked is that the computation time will be constant irrespective of how large N
$N$
is.
Although we do not wish to explore this particular trait of the prime number distribution sequence in any further detail, we can provide a basic implementation of block counting in the source code in section 10.3. Enthusiastic programmers may set the Boolean variable RowJ1
$RowJ1$
to TRUE to calculate the entire size of row j=0
$j=0$
, implemented for the subsequences P1
$P1$
and P3
$P3$
outside the i
$i$
and j
$j$
counters. The reader can easily observe the resultant gains made in terms of computational performance.
The block counting method has been experimented with to a greater extend by the author, resulting in the computation of (P(10^{10})) in less than 10
$10$
seconds, executed on an average 4
$4$
processor
2.49GHz machine. The executable that implements the unique approaches
for the effective first integer solutions of the Diophantine equation and combinatory mathematics is provided on the Nuclear Strategy, Inc. website.
However, the purpose of this paper is to prove that the existence of prime numbers is based on an orderly phenomenon; therefore, we now move on to discuss other open questions and the relevance of the prime number distribution sequence.
8. Twin primes and the Riemann Hypothesis
In section 5, we laid emphasis on building our model on the socalled 4
$4$
– 2
$2$
system. Now, we discuss the reasons for adopting the 4
$4$
– 2
$2$
system. However, we first revisit the definition of twin primes.
A twin prime is where two primes differ in value by two. The
first few twin primes are (3, 5), (5, 7), (11, 13), and so on. Recall
from our earlier (P_{2, 3}) formulation that a cyclic positioning of the divisor 3 approximately 2 has emerged, i.e., right and left of 2
and masked by 2
$2$
, for all 2×n
$2\times n$
, where n=1,2…
$n=1,2\dots $
and was the basis for the 4
$4$
–2
$2$
pattern, giving us the four integer solutions to equation [4].
Now, notice that the 4
$4$
–2
$2$
system is actually what lays the groundwork for the twin primes. Moreover, provided that the 4
$4$
–2
$2$
system is undisturbed, we would have infinitely many twin primes.
However, we note that the first nontwin prime is (23, 25). It is no coincidence that the smallest term of the prime number distribution sequence given by equation [5] is equal to 25
$25$
.
Consider the sequence (P_{1}), i.e., equation [6] for n=1
$n=1$
.When j=2
$j=2$
and i=0,1,2…
$i=0,1,2\dots $
, we know that 1/5th of all twin primes will vanish for all N<∞
$N<\infty $
. As we increment j
$j$
,
more twin primes will be wiped out, to a lesser degree, however. There
are three reasons for this. Firstly, the gaps between the i
steps rapidly increase as j
$j$
increases. Secondly, masking works in favor of the twin primes, or, generally speaking, for any primes. And lastly, as the 4–2
$4\u20132$
system clearly demonstrates, all j
$j$
will become cyclic and passive at some point. In the grand scheme of things, the cyclic behavior of the prime number distribution sequence explains why we unexpectedly come across isolated twin primes for very large N
$N$
.
Therefore, it is the task of the prime number distribution sequence to ensure twin primes cease to exist. If we can prove that, beyond some point, the terms of all P_{n} will at most differ by 2, then we can conclude absolutely that there will not be infinitely many twin primes. Of course, we know that this analysis can be carried out by considering the relationship between the i
$i$
and j
$j$
parameters of the sequence (P_{n}).
9. Conclusions
This paper attempts to demonstrate that the P(N
$P(N$
)problem is an inverse (or residual) stepwise phenomenon. This study also provides vigorous proofs, as well as the prime number distribution sequence, for the accurate and analytical calculation of P(N
$P(N$
). These analyses seem to contradict the Riemann hypothesis, where it is stated that the nontrivial zeros of the Riemann zeta function all have real part ½. It is evident that the Riemann hypothesis has been provided in the absence of prime number distribution analysis
and is based on an arbitrary analytical function. We conclude this
paper by stating that there is the very real possibility of deriving
infinitely many functions, for certain upper and lower boundaries of N
, to arrive at some reasonable approximation for P(N
$P(N$
); however, no real or complex variable function, or any constant values, will ever accurately predict P(N
$P(N$
) for all N→∞
$N\to \infty $
, as demonstrated in this paper.
10. Source Code
10.1. P_{2, 3 }formula
The below source code is written in Microsoft Excel VBA and can be implemented in the Sheet Cell function as =pTwoThree(N
$=pTwoThree(N$
). The function is applicable for when the input N
$N$
is less than 25
$25$
.
Function pTwoThree(N As Integer) As Integer
Dim P As Double
If N Mod 3 = 0 Then
P = N / 3
ElseIf (((N + 3 / 2  ((1) ^ N) / 2) / 3)  Int((N + 3 / 2  ((1) ^ N) / 2) / 3) = 0) Then
P = (N + 3 / 2  ((1) ^ N) / 2) / 3
ElseIf (((N + 3 / 2  ((1) ^ (N + 1)) / 2) / 3)  Int((N + 3 / 2  ((1) ^ (N + 1)) / 2) / 3) = 0) Then
If (((N  1) / 3)  Int((N  1) / 3) = 0) Then
P = ((N  1) / 3)
Else
P = (N + 3 / 2  ((1) ^ (N + 1)) / 2) / 3
End If
End If
pTwoThree = P + 1
End Function
10.2. Prime number distribution sequence in VBA
The below source code is written in Microsoft Excel VBA and can be implemented in the Sheet Cell function as =pNDS(N
$=pNDS(N$
). The function is applicable for when the input N
$N$
is less than 175
$175$
.
Function pNDS(N As Integer) As Integer
Dim P As Double
If N Mod 3 = 0 Then
P = N / 3
ElseIf (((N + 3 / 2  ((1) ^ N) / 2) / 3)  Int((N + 3 / 2  ((1) ^ N) / 2) / 3) = 0) Then
P = (N + 3 / 2  ((1) ^ N) / 2) / 3
ElseIf (((N + 3 / 2  ((1) ^ (N + 1)) / 2) / 3)  Int((N + 3 / 2  ((1) ^ (N + 1)) / 2) / 3) = 0) Then
If (((N  1) / 3)  Int((N  1) / 3) = 0) Then
P = ((N  1) / 3)
Else
P = (N + 3 / 2  ((1) ^ (N + 1)) / 2) / 3
End If
End If
pNDS = P + 1
j = 2
Do
For j = j To j + 1
For k = (1 / 4) * (1) ^ (j  2)  5 / 4 + (1 / 2) * j To 0 Step 1
For i = 1 To 0 Step 1
Pp = (i + j) * (3 * (3 / 2 + i) + (1 / 2) * (1) ^ i) + (1) ^ (i + j)  i  2 + k * (3 * (2 * j + 2 * i  1) + (1) ^ (i + j  2))
If Pp <= P Then
pNDS = pNDS  1
End If
Next i
Next k
Next j
Loop While Pp < P
End Function
10.3. Prime number distribution sequence in C++
The below source code is written in C++. The function is applicable for any input N
$N$
less than infinity.
// PNT.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
using namespace std;
double N, P23, Pi, Pj, i, uj, r, s, ui, PSx[4], PSy[4], PJS;
vector<double> T;
bool RowJ1 = false;
int _tmain(int argc, _TCHAR* argv[])
{
cout << "Copyright (c) 2014 by Yoldas Askan. ALL RIGHTS RESERVED." << '\n';
cout << "Please visit www.NuclearStrategy.co.uk for further details." << '\n' << '\n';
cout << "Enter interger N to compute count of primes in N: ";
cin >> N;
cout << '\n';
// Processor number
// There is no limit to the number of processors can be used for P(N) computations by pnds
int numProcessor = 4;
T.resize(numProcessor);
if(((int)N % 3) == 0.)
P23 = (int)(N / 3.);
else if( ((N + 3./2.  pow(1., N) / 2.) / 3.)  floor((N + 3./2.  pow(1., N) / 2.) / 3.) == 0.){
P23 = (int)(N + 3./2.  pow(1., N) / 2.) / 3.;
}
else if( ((N + 3./2.  pow(1., (N + 1.)) / 2.) / 3.)  floor((N + 3./2.  pow(1., (N + 1.)) / 2.) / 3.) == 0.){
if( ((N  1.) / 3.)  floor((N  1.) / 3.) == 0.){
P23 = ((int)(N  1) / 3.);
}
else
P23 = (int)(N + 3./2.  pow(1., (N + 1.)) / 2.) / 3.;
}
// base primes
PSx[0] = (2. + 3.); PSy[0] = (2. + 3.); PSx[1] = (2. + 3.); PSy[1] = (2. * 2.) + 3.;
PSx[2] = (2. * 2.) + 3.; PSy[2] = (2. * 2.) + 3.; PSx[3] = (2. * 2.) + 3.; PSy[3] = (3. * 3.) + 2.;
// Formulaic computation of row j = 0 for the sequences P1 and P3
// Set boolean variable RowJ1 to 'TRUE' to activate
RowJ1 = false;
PJS = 0.;
if(RowJ1)
PJS = 1.;
P1(0., PSx[0], PSy[0], 0., 1.);
P2(1., PSx[1], PSy[1], 1., 1.);
P3(2., PSx[2], PSy[2], 0., 1.);
P4(3., PSx[3], PSy[3], 1., 1.);
// Formulaic computation of row j = 0 for sequence P1 and p3
if(RowJ1){
// equation [6]
Pi = (((PSx[0] * PSy[0])+ 3./2.  pow(1., (PSx[0] * PSy[0] + 0.)) / 2.) / 3.) + 0. * (2 * PSx[0]);
Pj = (2 * PSy[0]) + (0. * (2 * (PSx[0] + 1.)));
T[0] += floor((P23  Pi) / Pj) + 1.;
T[0] = floor(((floor((P23  Pi) / Pj) + 1.)  PSx[0]) / PSx[2]) + 1.;
// equation [6]
Pi = (((PSx[2] * PSy[2])+ 3./2.  pow(1., (PSx[2] * PSy[2] + 0.)) / 2.) / 3.) + 0. * (2 * PSx[2]);
Pj = (2 * PSy[2]) + (0. * (2 * (PSx[2] + 1.)));
T[2] += floor((P23  Pi) / Pj) + 1;
}
for(int i = 0; i < numProcessor; i++){
// equation [7]
P23 = T[i];
}
P23++; // Is 2 a prime number?
cout << endl << "There are " << P23 << " primes in " << (int)N << '\n' << endl << endl;
system("pause");
return 0;
}
void P1(double I, double Sx, double Sy, double D, double E)
{
T[I] = 0.;
i = 0.;
do{
Pi = (((Sx * Sy)+ 3./2.  pow(1., (Sx * Sy + D)) / 2.) / 3.) + i * (2 * Sx); // equation [6]
Pj = (2 * Sy) + (i * (2 * (Sx + E)));
(floor((P23  Pi) / Pj) < i) ? uj = floor((P23  Pi) / Pj) : uj = i;
if(i > (2. * 2.)){ // Limit increments of j
if(RowJ1){
s = (3. + 2.);
r = (2. * 2.) + 3.;
if (i == s  floor((i  s) / r)  ((i  s) / r) == 0){
uj = 1.;
}
}
if(uj > 1.){
for(double w = 0; w < uj; w++){
s = (3. + 2.) + w * ((2. * 2.) + 3.);
r = (3. + 2.) + w * (3. * 2.);
if(s > i)
break;
if (i == s  floor((i  s) / r)  ((i  s) / r) == 0){
if(w < uj)
uj = w;
break;
}
}
}
}
for(double j = PJS; j <= uj; j++){
if(j > (2. * 2.)){ // Limit increments of i
for(double w = 1; w * (3. + 2.) <= j; w++){
s = (3. + 2.) + (w  1.) * ((2. * 2.) + 3.);
r = (3. + 2.) + (w  1.) * (3. * 2.);
if(s > j)
break;
if (j == s  floor((j  s) / r)  ((j  s) / r) == 0){
T[I];
break;
}
}
}
T[I]++;
}
i++;
}while(Pi + (PJS * Pj) <= P23);
}
void P2(double I, double Sx, double Sy, double D, double E)
{
T[I] = 0.;
i = 0.;
do{
Pi = (((Sx * Sy)+ 3./2.  pow(1., (Sx * Sy + D)) / 2.) / 3.) + i * (2 * Sx); // equation [6]
Pj = (2 * Sy) + (i * (2 * (Sx + E)));
(floor((P23  Pi) / Pj) < i) ? uj = floor((P23  Pi) / Pj) : uj = i;
if(i > 2.){ // Limit increments of j
for(double w = 0; w < uj; w++){
s = 3. + w * (3. + 2.);
r = (3. + 2.) + w * (3. * 2.);
if(s > i)
break;
if (i == s  floor((i  s) / r)  ((i  s) / r) == 0){
if(w < uj)
uj = w;
break;
}
}
}
if(uj > ((2. * 2.) + 3.)){
for(double w = 0; w < i; w++){
s = 2 * ((2. * 2.) + 3.) + (w * ((2. * 2.) + 3.));
r = (2. * 2.) + (3. * 3.) + (w * (3. * 2.));
if(s > i)
break;
if (i == s  ceil((i  s) / r)  ((i  s) / r) == 0){
if(uj > ((2. * 2.) + 3.))
uj = ((2. * 2.) + 3.);
break;
}
}
}
for(double j = 0; j <= uj; j++){
if(j > (2. * 2.)){ // Limit increments of i
for(double w = 1; w <= j; w++){
s = (3. + 2.) + (w  1.) * ((2. * 2.) + 3.);
r = (3. + 2.) + (w  1.) * (3. * 2.);
if(s > j)
break;
if (j == s  floor((j  s) / r)  ((j  s) / r) == 0){
T[I];
break;
}
}
}
T[I]++;
}
i++;
}while(Pi <= P23);
}
void P3(double I, double Sx, double Sy, double D, double E)
{
T[I] = 0.;
i = 0.;
do{
Pi = (((Sx * Sy)+ 3./2.  pow(1., (Sx * Sy + D)) / 2.) / 3.) + i * (2 * Sx); // equation [6]
Pj = (2 * Sy) + (i * (2 * (Sx + E)));
(floor((P23  Pi) / Pj) < i) ? uj = floor((P23  Pi) / Pj) : uj = i;
if(i > 2.){ // Limit increments of j
for(double w = 0; w < (i + ((3. * 2.) + 2.)) / ((3. * 3.) + 2.); w++){
s = 3. + w * (3. + 2.);
r = (3. + 2.) + w * (3. * 2.);
if(s > i)
break;
if (i == s  floor((i  s) / r)  ((i  s) / r) == 0){
uj = 1.;
break;
}
}
}
if(uj != 1.){
if(i > (3. * 2.)){
for(double w = 0; w < uj; w++){
s = ((2. * 2.) + 3.) + w * ((2. * 2.) + 3.);
r = ((2. * 2.) + 3.) + w * (3. * 2.);
if(s > i)
break;
if (i == s  floor((i  s) / r)  ((i  s) / r) == 0){
if(w < uj)
uj = w;
break;
}
}
}
}
for(double j = PJS; j <= uj; j++){
ui = false;
if(j > 2.){ // Limit increments of i
double w = 1;
for(w = 1; w <= j; w++){
s = 3. + (w  1.) * (3. + 2.);
r = (3. + 2.) + (w  1.) * (3. * 2.);
if(s > j)
break;
if (j == s  floor((j  s) / r)  ((j  s) / r) == 0){
T[I];
ui = true;
break;
}
}
}
if(j > (3. * 2.) && !ui){
double w = 1;
for(w = 1; w <= j; w++){
s = ((2. * 2.) + 3.) + (w  1.) * ((2. * 2.) + 3.);
r = ((2. * 2.) + 3.) + (w  1.) * (3. * 2.);
if(s > j)
break;
if (j == s  floor((j  s) / r)  ((j  s) / r) == 0){
T[I];
ui = true;
break;
}
}
}
T[I]++;
}
i++;
}while(Pi + (PJS * Pj) <= P23);
}
void P4(double I, double Sx, double Sy, double D, double E)
{
T[I] = 0.;
i = 0.;
do{
Pi = (((Sx * Sy)+ 3./2.  pow(1., (Sx * Sy + D)) / 2.) / 3.) + i * (2 * Sx); // equation [6]
Pj = (2 * Sy) + (i * (2 * (Sx + E)));
(floor((P23  Pi) / Pj) < i) ? uj = floor((P23  Pi) / Pj) : uj = i;
for(double w = 0.; w < ((3. * 2.) + 2.); w++){ // Limit increments of j
s = (2. * 2.) + (w * ((2. * 2.) + 3.));
r = (3. + 2.) + (w * (3. * 2.));
if(s > i)
break;
if (i == s  ceil((i  s) / r)  ((i  s) / r) == 0){
uj = 1.;
break;
}
}
if(uj != 1.){
for(double w = 0; w < (i + ((3. * 2.) + 2.)) / ((3. * 3.) + 2.); w ++){
s = (2. * 2.) + w * (3. + 2.);
r = ((2. * 2.) + 3.) + w * (3. * 2.);
if (i == s  floor((i  s) / r)  ((i  s) / r) == 0){
if(w < uj)
uj = w;
break;
}
}
}
for(double j = 0; j <= uj; j++){
ui = false;
if(j > 2.){ // Limit increments of i
double w = 1;
for(w = 1; w <= j; w++){
s = 3. + (w  1.) * (3. + 2.);
r = (3. + 2.) + (w  1.) * (3. * 2.);
if(s > j)
break;
if (j == s  floor((j  s) / r)  ((j  s) / r) == 0){
T[I];
ui = true;
break;
}
}
}
if(j > (3. * 2.) && !ui){
double w = 1;
for(w = 1; w <= j; w++){
s = ((2. * 2.) + 3.) + (w  1.) * ((2. * 2.) + 3.);
r = ((2. * 2.) + 3.) + (w  1.) * (3. * 2.);
if(s > j)
break;
if (j == s  floor((j  s) / r)  ((j  s) / r) == 0){
T[I];
ui = true;
break;
}
}
}
T[I]++;
}
i++;
}while(Pi <= P23);
}
This article was originally published by Nuclear Strategy, Inc. on http://nuclearstrategy.co.uk/primenumberdistributionseries