login
A331044
a(n) is the greatest prime number of the form floor(n/10^k) for some k >= 0, or 0 if no such prime number exists.
4
0, 0, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 0, 13, 0, 0, 0, 17, 0, 19, 2, 2, 2, 23, 2, 2, 2, 2, 2, 29, 3, 31, 3, 3, 3, 3, 3, 37, 3, 3, 0, 41, 0, 43, 0, 0, 0, 47, 0, 0, 5, 5, 5, 53, 5, 5, 5, 5, 5, 59, 0, 61, 0, 0, 0, 0, 0, 67, 0, 0, 7, 71, 7, 73, 7, 7, 7, 7, 7, 79, 0
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
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
See A331045 for a similar sequence.
Sequence in context: A269668 A061397 A331045 * A093438 A375548 A211396
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 08 2020
STATUS
approved