The previous prime function gives the largest prime
less than
.
The function can be given explicitly as
where
is the
th
prime and
is the prime counting
function. For
,
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).
Finding the previous prime before gives the largest
-digit prime. For
, 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
are 3, 3, 3, 3, 27, 9, 17, 9, 11, 63, ... (OEIS A033873).