16-2. Willans’s Formulas

C. P. Willans gives the following formula for the nth prime [Will]:

The derivation starts from Wilson’s theorem, which states that p is prime or 1 if and only if (p − 1)! ≡ −1(mod p). Thus,

is an integer for x prime or x = 1 and is fractional for all composite x. Hence

Equation 1

Thus, if π(m) denotes [2] the number of primes ≤ m,

[2] Our apologies for the two uses of π in close proximity, but it’s standard notation and ...

Get Hacker's Delight now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.