Willans' Formula

Willans' formula is a prime-generating formula due to Willan (1964) that is defined as follows. Let

={1 for j=1 or j prime; 0 otherwise

for j>1 an integer, where |_x_| is the floor function. This formula is a consequence of Wilson's theorem and conceals the prime numbers j as those for which F(j)=1, i.e., the values of F(j) are 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, ... (OEIS A080339). Then




where pi(m) is the prime counting function (Willans 1964; Havil 2003, pp. 168-169).

See also

Prime Formulas, Prime Number, Wilson's Theorem

Explore with Wolfram|Alpha


Havil, J. Gamma: Exploring Euler's Constant. Princeton, NJ: Princeton University Press, 2003.Sloane, N. J. A. Sequence A080339 in "The On-Line Encyclopedia of Integer Sequences."Willans, C. P. "A Formula for the nth Prime Number." Math. Gaz. 48, 413-415, 1964.

Cite this as:

Weisstein, Eric W. "Willans' Formula." From MathWorld--A Wolfram Web Resource.

Subject classifications