Talk:Legendre prime counting function: Difference between revisions
Content added Content deleted
m (added a section header to the first talk topic (discussion).) |
|||
Line 4: | Line 4: | ||
I checked and indeed pi(1) should be 0 (fixed that). Yes, the first prime would be 2.--[[User:Wherrera|Wherrera]] ([[User talk:Wherrera|talk]]) 17:27, 5 August 2021 (UTC) |
I checked and indeed pi(1) should be 0 (fixed that). Yes, the first prime would be 2.--[[User:Wherrera|Wherrera]] ([[User talk:Wherrera|talk]]) 17:27, 5 August 2021 (UTC) |
||
There are a few ways to exit the recursion: |
|||
One is to use the base case that pi(n) = 0 for n < 2. |
|||
Another method would be to keep a table of small primes (say primes <= 127) and count from the array when n is small. |
|||
the third method is to count from the sieved primes that you need to generate anyway, using a binary search, as the sieved primes could be large enough for binary search to be preferred. |
|||
In the examples, the CoffeeScript uses the identity pi(n) = 0 when n < 2. The Erlang version performs a binary search on the sieved primes (method 3.) |
|||
--[[User:Davgot|Davgot]] ([[User talk:Davgot|talk]]) 19:07, 5 August 2021 (UTC) |