TOPICS
Search

Previous Prime


The previous prime function PP(n) gives the largest prime less than n. The function can be given explicitly as

 PP(n)=p_(pi(n-1)),

where p_i is the ith prime and pi(n) is the prime counting function. For n=3, 4, ... the values are 2, 3, 3, 5, 5, 7, 7, 7, 7, 11, 11, 13, 13, 13, 13, 17, 17, 19, ... (OEIS A007917).

The previous prime function was implemented in versions of the Wolfram Language prior to 6 as PreviousPrime[n] (after loading the package NumberTheory`NumberTheoryFunctions).

PreviousPrime

Finding the previous prime before 10^n gives the largest n-digit prime. For n=1, 2, ..., the first few of these are 7, 97, 997, 9973, 99991, 999983, 9999991, 99999989, ... (OEIS A003618). The amounts by which these are less than 10^n are 3, 3, 3, 3, 27, 9, 17, 9, 11, 63, ... (OEIS A033873).


See also

Next Prime, Prime Counting Function, Prime Number

Explore with Wolfram|Alpha

References

O'Hara, F. "More Prime Trivia." J. Recr. Math. 20, No. 3, 209-210, 1988.O'Hara, F. "The Smallest and Largest N-Digit Primes for N=1(1)150." J. Recr. Math. 22, No. 4, 277-279, 1990.Ondrejka, R. "Prime Trivia." J. Recr. Math. 14, No. 4, 285, 1981-1982.Sloane, N. J. A. Sequences A003618/M4452, A007917, and A033874 in "The On-Line Encyclopedia of Integer Sequences."

Referenced on Wolfram|Alpha

Previous Prime

Cite this as:

Weisstein, Eric W. "Previous Prime." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/PreviousPrime.html

Subject classifications