OFFSET
0,3
COMMENTS
In other words, a(n) is the greatest prime prefix of n, or 0 if every prefix of n is nonprime.
This sequence is a decimal variant of A039634.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
FORMULA
a(n) <= n with equality iff n = 0 or n is a prime number.
a(n) >= 0 with equality iff n belongs to A202259.
EXAMPLE
For n = 42:
- neither 42 nor 4 is a prime number,
- hence a(42) = 0.
For n = 290:
- 290 is not a prime number,
- 29 is a prime number,
- hence a(290) = 29.
PROG
(PARI) a(n, base=10) = while (n, if (isprime(n), return (n), n\=base)); 0
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 08 2020
STATUS
approved