# result of my prime counting function

#### youngmath

pi(n) = number of primes less than n
i proved that:
pi(n) - pi(âˆšn) = n Ã— (1/2 Ã— 2/3 Ã— ... Ã— p-1/p)
p = largest prime less than or equal to âˆšn
prime number theorem: pi(n) = n/ln(n)
lim pi(âˆšn) / pi(n) = lim âˆšn/ln(âˆšn) / n/ln(n) = lim 2/âˆšn = 0
=> pi(n) - piâˆšn ~ pi(n) = n Ã— (1/2 Ã— 2/3 Ã— ... Ã— p-1/p)
p < âˆšn
and
pi(n^2) = n^2 Ã— (1/2 Ã— 2/3 Ã— ... Ã— q-1/q)
q < n
=> pi(n^2)/pi(n) = n Ã— ( p-1/p Ã— ... Ã— q-1/q)
p > âˆšn , q < n
and
pi(n^2)/pi(n) = n^2/ln(n^2) / n/ln(n) = n/2
=> n/2 = n Ã— (p-1/p Ã— ... Ã— q-1/q)
=> lim p-1/p Ã— ... Ã— q-1/q = 1/2
p>âˆšn , q<n
for n=100 it is 0.526 ~ 1/2
for n=1000 it is 0.513 ~ 1/2

#### Maschke

pi(n) - pi(âˆšn) = n Ã— (1/2 Ã— 2/3 Ã— ... Ã— p-1/p)
I assume the last factor is $(p-1)/p$.

I calculated $\pi(100,000) - \pi(sqrt(100,000)) = 9527$ and

$\displaystyle 100,000 \times \prod_{p < 316, \\ p \ \text{prime}} \frac{p-1}{p} = 9307.8...$

So there's some drift there. Note that sqrt(100,000) is around 316.

ps -- For n = 1,000,000 and p = 997 I got 78,330 for the left hand side of your equation and 80965.2... for the right side.

I used Wolfram Alpha to calculate the LHS and wrote a little Python program to calculate the RHS. I didn't bother to work out the primes, I just copied them into a list from here.

Can you imagine what Gauss and Euler would have done with tools like these? Probably wasted their lives looking at LOLCats and arguing with circle squarers and angle trisectors.

Last edited:

#### Maschke

Oh. Correction on the calculation of the RHS for n = 100000. I now get 9651.

Last edited:

#### youngmath

can you calculate 100/101 Ã— ... Ã— 9972/9973 ?

Last edited:

#### youngmath

lim (p-1)/p Ã— ... Ã— (q-1)/q = 1/2
âˆšn<p , q<n
for n=10000 p=101 q=9973
100/101 Ã— ... Ã— 9972/9973 = 0/506 ~ 1/2
for n=100 product is 0.526
for n=1000 product is 0.513
and for n=10000 it is 0.506

#### Maschke

lim (p-1)/p Ã— ... Ã— (q-1)/q = 1/2
âˆšn<p , q<n
for n=10000 p=101 q=9973
100/101 Ã— ... Ã— 9972/9973 = 0/506 ~ 1/2

Where does $q$ come from? This is a little confusing. Is this limit taken as both $n$ and $q$ go to infinity independently? Or does it relate to $n$ and $p$? Can you clarify please?

ps -- Oh I see, I didn't understand what you were asking earlier. My post #5 is wrong. Earlier we were calculating 1/2 x 2/3 x 4/5 x ... (p-1)/p and I thought we were still doing that. But now you are multiplying all the values of (p-1)/p for p between two arbitrary primes. Didn't realize that.

My post #2 and the correction in #3 are still correct. And actually the product of (p-1)/p between two primes r and q is just the product from 1 to q divided by the product from 1 to the prime before r. If I'm understanding your latest notation.

Last edited by a moderator:

#### Maschke

can you calculate 100/101 Ã— ... Ã— 9972/9973 ?
Ok I calculated this and got 0.5060344379058458.

What is the significance of 101 and 9973? What limit are you taking? Do 101 and 9973 independently go to infinity? How are they chosen?

I know that for n = 10,000, sqrt(10,000) = 100 and so p = 101 is the first prime larger than sqrt(10,000).

I know 9973 is the largest prime less than 10,000.

Ah ... is this starting to make sense? You take the smallest prime larger than sqrt(n) and the largest prime smaller than n ... ok now I get it. So the limit as n goes to infinity should be 1/2.

I wonder if someone can prove this.

Last edited:

#### youngmath

can you calculate it for n=100000 and n=1000000

#### Maschke

can you calculate it for n=100000 and n=1000000
Yes, why? We've already done larger numbers.