A different way to count prime numbers.

binbots

New member
Joined
Apr 24, 2020
Messages
2
I found a simple and interesting way to count prime numbers. If this has been discovered before, what is it called and why have I never seen it? It seems like something that would be very well documented.
Add all the prime numbers to any prime number. Then add the last prime number again. The result will be approximately equal to the number of primes below the last prime number squared. For example: (2+3+5+7+11)+11=39. The number of prime numbers under 11 squared (121) is 30. The larger the integers get the more accurate by proportion this seems to become. For example:
349
(2+3+5+7+11+13….+349)+349=11,258. 349 squared is 121,801. The number of primes below this number is 11,460. A difference of only 202.
104,729
(2+3+5+7+11+13…..+104,729)+104,729=496,270,140. 104,729 squared is 10,968,163,441. The number of primes below this number is 497,001,078. A difference of only 730,938 primes.
1,000,003
(2+3+5+7+11+13…..+1,000,003)+1,000,003=37,552,402,029. 1,000,003 squared is 1,000,006,000,009. The number of primes below this number is 37,608,128,827. A difference of 55,726,798 primes.
4,999,999
(2+3+5+7+11+13….+4,999,999)+4,999,999=838,601,693,107. 4,999,999 squared is 24,999,990,00,001. The number of primes below this number is 838,538,039,510. A difference of 63,653,597.
This formula can also be reversed to find the approximate number of primes under any integer. Take any number and square root it. Then add all the primes below that squared root number and add the last prime again. For example: To find the number of primes below 100 you take the square root (10). Adding the prime numbers under 10 plus the last prime again is (2+3+5+7)+7=24. The actual amount is 25. Here are some larger examples:
2,000,000
The square root of 2,000,000 is 1414. The highest prime below 1414 is 1409. So (2+3+5+7+11+13….+1409)+1409=144,522. The real answer is 148,933. A difference of 4,411.
4,000,000
The square root of 4,000,000 is 2,000. The highest prime below 2,000 is 1999. So (2+3+5+7+11+13…+1999)+1999=277,050. The real answer is 283,146. A difference of 11,096.
 
binbots, your method needs tweaking.

For one prime to nine primes added, you do not add the largest prime back to
the sum as follows for the optimum result:

2 vs. pi(4) = 2

2 + 3 = 5 vs. pi(9) = 4

2 + 3 + 5 = 10 vs. pi(25) = 9

17 vs. 15

28 vs. 30

41 vs. 39

58 vs. 61

77 vs. 72

2 + ... + 23 = 100 vs. pi(23^2) = 99

Then there are long stretches where adding back the last prime number is better
or not doing that. It depends as there is a lot of switching back and forth. Ultimately, as the number of primes to be added gets to be
large, on average, you have to start adding two times the largest prime to the sum,
later, three times the largest prime to the sum, etc.

Here is an example of the latter:

The 800th prime number is 6,133. The sum of the first 800 prime numbers is
2,277,959. The number of prime numbers less than (6,133^2) = 2,296,879.

2,277,959 + 3*6,133 = 2,296,358

See how we need to add three times the largest prime back to the sum to get
closest to the number of primes less than that target number.
 
Last edited:
Thank you. I was thinking the same thing and looking into it. I just didn't say anything because I was trying to keep it as simple as possible.
 
Top