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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.