# How to find prime numbers

I am looking for a formula that tells me what the next prime number will be. It is hard to do this without a formula because for example there is a small gap between 17 and 19 then a big one between 23 and 29 so it is sometimes hard to find the next one quickly.

• There is no formula for the next prime number - they behave randomly, at least at the small scale. However, we do know something about how they are distributed (you mentioned the "gap" between successive primes) see here en.wikipedia.org/wiki/Prime_number_theorem or see here en.wikipedia.org/wiki/Prime_number#Formulas_for_primes May 10 '13 at 12:27
• What is it with prime numbers and formulas today? What you ask is impossible. All you can do is search. May 10 '13 at 12:27
• This is a similar question: math.stackexchange.com/questions/164767/… May 10 '13 at 12:27
• I don't think such a formula (short than factor all numbers...) exists.
– mau
May 10 '13 at 12:27
• You might want to try this Mathematica command in Wolfram Alpha: Table[(Exp[MangoldtLambda[n]]^(-MoebiusMu[n]) - 1)/(n - 1)*n, {n, 2, 32}] which outputs: {2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 0, 13, 0, 0, 0, 17, 0, 19, 0, 0, 0, 23, 0, 0, 0, 0, 0, 29, 0, 31, 0} May 10 '13 at 12:35