You are on page 1of 11

Notes on Number Theory and Discrete Mathematics

Print ISSN 1310–5132, Online ISSN 2367–8275


Vol. 27, 2021, No. 4, 129–139
DOI: 10.7546/nntdm.2021.27.4.129-139

Formulas for the n-th prime number


Krassimir T. Atanassov
Department of Bioinformatics and Mathematical Modelling
IBPhBME – Bulgarian Academy of Sciences
Acad. G. Bonchev Str., Bl. 105, Sofia-1113, Bulgaria
e-mail: krat@bas.bg

Received: 2 August 2021 Revised: 25 October 2021 Accepted: 1 November 2021

Abstract: A short review of formulas for the n-th prime number is given and some new formulas
are introduced.
Keywords: Arithmetic function, Prime number.
2020 Mathematics Subject Classification: 11A25, 11A41.

1 Introduction
The work on the present paper started around 2015. Section 3 was completed in the middle
of 2018, when I decided that it will be better if there is a computational evaluation of the
effectiveness of the formulas for the n-th prime number pn , described in this paper. I asked my
former PhD student—now Associate Professor—Dimitar Dimitrov to implement in software this
idea and make a detailed comparison of the computation times that different existing formulae
require to compute the n-th prime. His work resulted in his publication [10], where my research
was referenced as “unpublished manuscript”. Dimitrov found in the literature and included in his
research, four new formulas—three of S. M. Ruiz and one of I. Kaddoura and S. Abdul-Nabi—
which I also am adding in my literature review in Section 2.
While the motivation of his paper was that “unpublished manuscript” of mine, back in that
moment in 2019 I was working on other research problems and I delayed the present publication
hoping that some other formulas are on the way. By these reasons, only now, two years later, I
have revisited my research and I have added four new formulas in Section 4.

129
2 Some formulas for the n-th prime number
Although the problem for finding an explicit formula for the n-th prime number is very old, it
obtained solutions even in the second part of the last century.
Probably, the first explicit formula giving the n-th prime number pn was introduced in 1962
by L. Veshenevskiy in [21]. It has the form:
n−k2 (n−k2 ).(n−k2 −k3 ) (n−k2 ).(n−k2 −k3 ).(n−k2 −k3 −k4 )
1 + (−1)2 1 + (−1)2 1 + (−1)2
pn = 2 + + + +...
2 2 2
where
(2−2.2)2
1 + (−1)2
k2 = ,
2
(3−2.2)2 .(3−2.3)2 .(3−3.2)2
1 + (−1)2
k3 = ,
2
···
2 2 2 2 2 2 2 2 2 2
2(t−2.2) .(t−2.3) ...(t−2.t) (t−3.2) .(t−3.3) ...(t−3.(t−1)) ...(t−m.2) .(t−m.3) ...(t−m.(t−m+2)) ...(t−t.2)
1 + (−1)
kt = .
2
In Paulo Ribenboim’s book [16], three other formulas for pn are discussed. The first of them
is introduced in 1964 by C. P. Willans [22]. For every integer j ≥ 1 let
 
2 (j − 1)! + 1
F (j) = cos π
j
and
π{(j−1)!}2
" #
sin2 j
H(j) = 2 π ,
sin ( j )
where [x] is the integer part of the real number x.
Let π be the well-known prime counting function. Then it satisfies the equalities
n
X
π(n) = −1 + F (j)
j=1

and n
X
π(n) = H(j).
j=2

Hence, for the natural number n ≥ 2


 1/n 
2n 
X  n  
pn = 1 + 
 m
P
 
 
F (j)
m=1
 
j=1
 1/n 
2 n " 1/n # 2n 
X n X  n  
=1+ =1+  m
  .
1 + π(m)  P  
1+ H(j)
m=1 m=1

j=2

130
In 1971 J. M. Gandhi [11] introduced the recurrent formula
  
1 1 X µ(d) 
pn = 1 − log − + ,
log 2 2 2d − 1
d|Pn−1

where µ is the well-known Möbius function and Pn−1 = p1 . . . pn−1 , with p1 , . . . , pn−1 already
calculated prime numbers.
Following [16], we note that J. Minač in an unpublished paper gave the formula
n   
X (j − 1)! + 1 (j − 1)!
π(n) = − .
j=2
j j

Now, for pn , e.g., Willans formula can be used with the new form of π(n).
In 2000 and 2005, S. M. Ruiz introduced the following three formulas [17, 18]:
[2n log n+2] j  
" k
"  !#!#!
X 1X 1 X j j−1
pn = 1 + 1− 1+ 2− −
k=1
n j=2
j s=1
s s
[2n log n+2]
" k  #!
X 1X LCM(1, 2, . . . , j)
pn = 1 + 1− ,
k=1
n j=2
j. LCM(1, 2, . . . , j − 1)
[n log n+n(log(log n)−0.5)+3]
" k  #!
X 1X LCM(1, 2, . . . , j)
pn = [n log n] + 1− ,
n j=2 j. LCM(1, 2, . . . , j − 1)
k=[n log n]

and in 2012, I. Kaddoura and S. Abdul-Nabi in [12] give the formula:


 P  x−1  P  x+1  
[2n log n+2] 4 + 6
[S(6j + 1)] + 6
[S(6j − 1)]
X  j=1 j=1
pn = 3 + 2[n log n] − ,

n

x=7

where h √ i
[ x]
6
+1
x x
P     x  x

k=1 6k+1
− 6k+1 + 6k−1 − 6k−1
S(x) = − h √ i  .
2 [ 6x] + 1
In [3, 8, 9], the author introduced four other explicit formulas, giving the n-th prime number.
First, let us define functions sg, sg and fr by:
( (
0, if x ≤ 0 0, if x 6= 0
sg(x) = , sg(x) = ,
1, if x > 0 1, if x = 0

where x is a real number and


  (
p 0, if p = 1
fr = ,
q 1, if p 6= 1

where p and q are natural numbers, such that (p, q) = 1.

131
Let the natural number n > 1 have a canonical representation
k
Y
n= pαi i , (1)
i=1

where p1 , . . . , pk are distinct prime numbers and α1 , . . . , αk ≥ 1 are natural numbers.


The well-known arithmetic functions ϕ, ψ and σ (see, e.g., [14, 15]) have the forms:
k
Y
ϕ(n) = pαi i −1 (pi − 1), ϕ(1) = 1,
i=1
Yk
ψ(n) = pαi i −1 (pi + 1), ψ(1) = 1,
i=1
k
Y pαi i +1 − 1
σ(n) = , σ(1) = 1.
i=1
pi − 1

The following four representations of function π hold for every natural number n ≥ 2 with
canonical form (1) (here and below, the index of the function π corresponds to the function, that
is used in the representation):
n
X
πϕ (n) = sg(j − 1 − ϕ(j));
j=2
n
X
πψ (n) = sg(ψ(j) − j − 1);
j=2
n
X
πσ (n) = sg(σ(j) − j − 1);
j=2
n  
X j
πfr (n) = fr .
j=2
(j − 1)!

In [8], the author used the arithmetic function η, given for the natural number n ≥ 2 with
canonical form (1) by
Xn
η(n) = αi .pi ,
i=1

for constructing the following new formula for π:


n
X
πη (n) = sg(j − η(j)).
j=2

In 1987, the author introduced an arithmetic function with properties similar to the operation
“differentiation” [1, 6]. For a natural number n ≥ 2, with the canonical form (1), it has the form:
k
X α
i−1 αi −1 α
δ(n) = αi pα1 1 . . . pi−1 pi pi+1i+1
. . . pαk k .
i=1

132
Obviously, if p is a prime number, then from the definition it follows that

δ(p) = 1.

In [9], the author used this function for constructing the following formula for π:
n  
X 1
πδ (n) = .
j=2
δ(j)

If π is one of the representations πϕ , πψ , πσ , πf r , πη , πδ , then for every natural number n:


C(n)
X
pn = sg(n − π(i)),
i=0

where (see [13, 5.27, p. 90])


n2 + 3n + 4


C(n) = .
4
Therefore, the formula for n-th prime number admits the forms
C(n) i
!
X X
pn = sg n − sg(j − 1 − ϕ(j))
i=0 j=2
C(n) i
!
X X
pn = sg n − sg(ψ(j) − j − 1)
i=0 j=2
C(n) i
!
X X
pn = sg n − sg(σ(j) − j − 1)
i=0 j=2
C(n) i  !
X X j
pn = sg n − fr
i=0 j=2
(j − 1)!
C(n) i
!
X X
pn = sg n − sg(j − η(j))
i=0 j=2
C(n) i  !
X X 1
pn = sg n − ,
i=0 j=2
δ(j)

b
P
where • = 1 for a > b.
i=a
In [20] Mladen Vassilev-Missana, continuing the idea from [3], proposed the following three
formulas:
 
C(n)
X 1 
pn =    ,
 π(j) 
j=0 1+
n
C(n)   
X π(j)
pn = −2. ζ −2. ,
j=0
n

133
C(n)
X 1
pn =    ,
π(j)
j=0 Γ 1−
n

where π(j) can be evaluated by some one of the above formulas, ζ is Riemann’s Zeta-function
and Γ is Euler’s Gamma-function.

3 New formulas for the n-th prime number1


First, we give the following new representations of formulas for πϕ , πψ , and πσ :
n  
X ϕ(j)
πϕ (n) = ,
j=2
j−1
n  
Xj+1
πψ (n) = ,
j=2
ψ(j)
n  
X j+1
πσ (n) = .
j=2
σ(j)

These formulas are equivaled to the previous ones, because if j is a prime number, then
 
ϕ(j)
= sg(j − 1 − ϕ(j))
j−1
 
j+1
= = sg(ψ(j) − j − 1)
ψ(j)
 
j+1
= = sg(σ(j) − j − 1) = 1
σ(j)

and if j is a composite number, then


 
ϕ(j)
= sg(j − 1 − ϕ(j))
j−1
 
j+1
= = sg(ψ(j) − j − 1)
ψ(j)
 
j+1
= = sg(σ(j) − j − 1) = 0.
σ(j)

Second, we introduce the following three well-known arithmetic functions (see, e.g., [14,15]),
related to the canonical representation (1) of the natural number n ≥ 2:
k
Y
τ (n) = (1 + αi )
i=1

ω(n) = k,
1
New, for the middle of 2018.

134
and
k
X
Ω(n) = αi .
i=1

Obviously, for every prime number p,

ω(p) = ω(p2 ) = ω(p3 ) = · · · = 1.

Let a natural number n ≥ 2 is given by (1) and p1 is the minimal prime numbers among
p1 , . . . , pk . We introduce function ω by

ω(n) = α1 ω(n).

Then,
ω(n) = 1
if and only it n is a prime number.
Now, we can introduce the following three new formulas for the value of π:
n n  
X X 1
πτ (n) = sg(τ (j) − 2) =
j=2 j=2
τ (j) − 1
n n  
X X 1
πω (n) = sg(ω(j) − 1) = ,
j=2 j=2
ω(j)

and
n n  
X X 1
πΩ (n) = sg(Ω(j) − 1) = .
j=2 j=2
Ω(j)

For the three cases, if j is a prime number, then


 
1
= sg(τ (j) − 2)
τ (j) − 1
 
1
= = sg(ω(j) − 1)
ω(j)
 
1
= = sg(Ω(j) − 1) = 1.
Ω(j)

On the other hand, if j is a composite number, then τ (j) − 1 > 1, ω(j) > 1 and Ω(j) > 1, and
 
1
= sg(τ (j) − 2)
τ (j) − 1
 
1
= = sg(ω(j) − 1)
ω(j)
 
1
= = sg(Ω(j) − 1) = 0.
Ω(j)

Therefore, the sum in the right-hand side of πτ (n), πω (n)and πΩ (n) is equal to π(n).

135
Finally, we can define function P over the natural number n ≥ 2 with canonical representation
(1), by: 
1, if n is a prime number
P(n) = .
0, if n is a composite number

Then n
X
πP (n) = P(j).
j=2

Theorem 3.1. For every natural number n:


C(n)
X
pn = sg(n − πτ (i)), (2)
i=0
C(n)
X
pn = sg(n − πω (i)), (3)
i=0
C(n)
X
pn = sg(n − πΩ (i)), (4)
i=0
C(n)
X
pn = sg(n − πP (i)). (5)
i=0

Proof. Let us remind the fact (see [13]) that

pn < C(n)

for every natural number n. Now, we can see that for a fixed natural number n, the expressions
n − πτ (i), n − πω (i), n − πΩ (i), and n − πP (i) are monotonically decreasing with respect to i,
and same is valid for sg(n − πτ (i)), sg(n − πω (i)), sg(n − πΩ (i)) and sg(n − πP (i)). When
i = 0, 1, . . . , pn − 1, the numbers n − πτ (i), n − πω (i), n − πΩ (i), and sg(n − πP (i)) are equal
to 1, and when i ≥ pn , these numbers are equal to 0.
Therefore, the sums in (2), (3), (4), and (5) contain exactly pn in number units, that proves the
Theorem.

As a corrolary, we obtain the representations;


C(n) i  !
X X 1
pn = sg n−
i=0 j=2
τ (j) − 1
C(n) i  !
X X 1
pn = sg n−
i=0 j=2
ω(j)
C(n) i  !
X X 1
pn = sg n− ,
i=0 j=2
Ω(j)
C(n) i  !
X X 1
pn = sg n− .
i=0 j=2
Ω(j)

136
At the end, we mention that the following Open Problem is interesting: Which formula for
pn has the minimal computational compexity?

4 Instead of Conclusion: Four new formulas


for the n-th prime number
During the last 25 years, the author introduced some new arithmetic functions that also can be
used for determination of the n-th prime number. They are (using representation (1) for n):

• Irrational factor [2, 19]:


k
Y 1/αi
IF (n) = pi ,
i=1

• Converse factor [4, 19]:


k
Y
CF (n) = αipi ,
i=1

• Restrictive factor [5, 19]:


k
Y
RF (n) = pαi i −1 ,
i=1

• a function, in some sense dual to σ [7]


k
Y
χ(n) = (pαi i − pαi i −1 + · · · + (−1)αi −1 pi + (−1)αi )
i=1

For these functions we obtain:


n  
X 1
πIF (n) = ,
i=2
ω(n)IF (n)
n  
X 1
πCF (n) = ,
i=2
ω(n)CF (n)
n  
X 1
πRF (n) = ,
i=2
ω(n)RF (n)
n
X
πχ (n) = sg(j − 1 − χ(j))
j=2

and
C(n) C(n) C(n) C(n)
X X X X
pn = sg(n − πIF (i)) = sg(n − πCF (i)) = sg(n − πRF (i)) = sg(n − πχ (i)).
i=0 i=0 i=0 i=0

137
References
[1] Atanassov, K. (1987). New integer functions, related to “ϕ” and “σ” functions. Bulletin of
Number Theory and Related Topics, XI(1), 3–26.

[2] Atanassov, K. (1996). Irrational factor: definition, properties and problems. Notes on
Number Theory and Discrete Mathematics, 2(3), 42–44.

[3] Atanassov, K. (2001). A new formula for the n-th prime number. Comptes Rendus de
l’Academie Bulgare des Sciences, 54(7), 5–6.

[4] Atanassov, K. (2002). Converse factor: Definition, properties and problems. Notes on
Number Theory and Discrete Mathematics, 8(1), 37–38.

[5] Atanassov, K. (2002). Restrictive factor: Definition, properties and problems. Notes on
Number Theory and Discrete Mathematics, 8(4), 117–119.

[6] Atanassov, K. (2004). On an arithmetic function. Advanced Studies on Contemporary


Mathematics, 8(2), 177–182.

[7] Atanassov, K. (2009). A remark on an arithmetic function. Part 2. Notes on Number Theory
and Discrete Mathematics, 15(3), 21–22.

[8] Atanassov, K. (2009). A remark on an arithmetic function. Part 3. Notes on Number Theory
and Discrete Mathematics, 15(4), 23–27.

[9] Atanassov, K. (2013). A formula for the n-th prime number. Comptes Rendus de l’Academie
bulgare des Sciences, 66(4), 503–506.

[10] Dimitrov, D. (2019). On the software computation of the formulae for the n-th prime
number. Notes on Number Theory and Discrete Mathematics, 25(3), 198–206.

[11] Gandhi, J. (1971). Formulae for the nth prime. Proceedings of the Washington State
University Conference on Number Theory, Washington State University, Pullman, 96–101.

[12] Kaddoura, I., & Abdul-Nabi, S. (2012). On Formula to Compute Primes and the nth Prime.
Applied Mathematical Sciences, 6(76), 3751–3757.

[13] Mitrinović, D., & Popadić, M. (1978). Inequalities in Number Theory, University of Niś.

[14] Mitrinovic, D., & Sándor, J. (1996). Handbook of Number Theory, Kluwer Academic
Publishers.

[15] Nagell, T. (1950). Introduction to Number Theory, John Wiley & Sons, New York.

[16] Ribenboim, P. (1995). The New Book of Prime Number Records, Springer, New York.

[17] Ruiz, S. M. (2005). A new formula for the nth prime. Smarandache Notions Journal, Vol.
15.

138
[18] Ruiz, S. M. (2000). A functional recurrence to obtain the prime numbers using the
Smarandache Prime Function. Smarandache Notions Journal, 11(1-2-3), 56–58.

[19] Sándor, J., & Atanassov, K. T. (2021). Arithmetic Functions, Nova Science Publishers, Inc.

[20] Vassilev-Missana, M. (2001). Three formulae for n-th prime and six for n-th term of twin
primes. Notes on Number Theory and Discrete Mathematics, 7(1), 15–20.

[21] Veshenevskiy, L. (1962). A formula for determining of the prime number using its ordinal
number. Matematika v Shkole, 5, 74–75 (in Russian).

[22] Willans, C. (1954). On formulae for the nth prime. The Mathematical Gazette, 48, 413–415.

139

You might also like