OFFSET
1,1
EXAMPLE
13 is a term since the last digits of 11 and 13 are 1, 3.
139339 is a term since the last digits of the 6 primes before and including it are: 1, 3, 9, 3, 3, 9.
MATHEMATICA
pOK[p_]:=Module[{l=IntegerLength[p], s={IntegerDigits[p][[-1]]}}, Do[PrependTo[s, Last[IntegerDigits[NextPrime[p, -i]]]], {i, l-1}]; s==IntegerDigits[p]]; Select[Prime[Range[10^5]], pOK] (* James C. McMahon, Oct 14 2025 *)
PROG
(Python)
from sympy import isprime, prevprime
from itertools import count, islice, product
def ok(n):
if not isprime(n): return False
d, p = list(map(int, str(n))), prevprime(n)
for i in range(2, len(d)+1):
if p%10 != d[-i]: return False
p = prevprime(p)
return True
def agen(): # generator of terms
yield from [2, 3, 5, 7]
yield from (k for d in count(2) for t in product("1379", repeat=d) if ok(k:=int("".join(t))))
print(list(islice(agen(), 13))) # Michael S. Branicky, Oct 06 2025
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
Morné Louw, Oct 01 2025
EXTENSIONS
a(14) from Michael S. Branicky, Oct 06 2025
a(15) from Michael S. Branicky, Oct 13 2025
STATUS
approved
