- **Information & Answers**
(*https://www.mersenneforum.org/forumdisplay.php?f=38*)

- - **Legendre's prime counting function**
(*https://www.mersenneforum.org/showthread.php?t=15765*)

Legendre's prime counting functionI am reading the discussion of the prime counting function in pages 10 through 34 of the second edition of Hans Riesel's book "Prime Numbers and Computer Methods for Factorization" and writing programs to compute pi(x) and phi(x,a) based on that discussion. Reisel gives two equations:
1.9: phi(x,a) = phi(x,a-1) - phi(x/p[a],a-1) 1.26: pi(x) = phi(x,a) + a - 1, with a = pi(sqrt x) Here p[n] is the nth prime, with p[1]=2. So I wrote a couple of quick little programs and calculated pi(10^6) = phi(10^6,168) + 167 = 78331 + 167 = 78498, which is correct. But then I noticed that I had made an error in my program, and instead of calculating a = pi(sqrt 10^6) = 168 I calculated a = p[sqrt 10^6] = 7919. Then pi(10^6) = phi(10^6,7919) + 7919 - 1 = 70580 + 7919 - 1 = 78498, which is also correct. My result holds for all the values of pi(x) that I attempted. Have I done something wrong? Or have I inadvertently done something right? Phil |

All times are UTC. The time now is 12:06. |

Powered by vBulletin® Version 3.8.11

Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.