login
A331097
a(n) is the greatest prime number of the form n mod (10^k) for some k > 0, or 0 if no such prime number exists.
3
0, 0, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 2, 13, 0, 5, 0, 17, 0, 19, 0, 0, 2, 23, 0, 5, 0, 7, 0, 29, 0, 31, 2, 3, 0, 5, 0, 37, 0, 0, 0, 41, 2, 43, 0, 5, 0, 47, 0, 0, 0, 0, 2, 53, 0, 5, 0, 7, 0, 59, 0, 61, 2, 3, 0, 5, 0, 67, 0, 0, 0, 71, 2, 73, 0, 5, 0, 7, 0, 79, 0
OFFSET
0,3
COMMENTS
In other words, a(n) is the largest prime suffix of n, or 0 if no such suffix exists.
LINKS
FORMULA
a(n) <= n with equality iff n = 0 or n is a prime number.
EXAMPLE
For n = 42:
- 42 mod (10^k) = 42 is not prime for k >= 2,
- 42 mod 10 = 2 is prime,
- hence a(42) = 2.
PROG
(PARI) a(n, base=10) = my (d=digits(n, base), s); for (k=1, #d, if (isprime(s=fromdigits(d[k..#d], base)), return (s))); 0
CROSSREFS
Cf. A047814, A331044, A331102 (binary analog).
Sequence in context: A093438 A375548 A211396 * A047814 A365276 A101991
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 09 2020
STATUS
approved