Previous Prime

Author

Eric W. Weisstein
May 5, 2007

This notebook downloaded from http://mathworld.wolfram.com/notebooks/PrimeNumbers/PreviousPrime.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/PreviousPrime.html.

©2007 Wolfram Research, Inc. except for portions noted otherwise

Initialization

PreviousPrime[n_Integer]:=Block[{i=n},While[!PrimeQ[--i]];i]
SetAttributes[PreviousPrime,Listable];

Sequence

PreviousPrime[Range[20]]

Formula

PP[n_]:=Prime[PrimePi[n-1]]

Subtract@@@Table[{PP[n],PreviousPrime[n]},{n,3,20}]

Largest n-Digit Primes

PreviousPrime[10^#]&/@Range[20]

(10^#-PreviousPrime[10^#])&/@Range[0,20]

IntegerListPlot[(10^#-PreviousPrime[10^#])&/@Range[0,100],
AxesLabel->TraditionalForm/@{n,10^n-PP[10^n]}]