OFFSET
0,3
COMMENTS
In other words, a(n) is the largest prime suffix of n, or 0 if no such suffix exists.
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.
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
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 09 2020
STATUS
approved