login
A389353
Primes p which are the concatenation of the last digits of the length(p) primes before and including p, where length(p) is the number of digits of p.
0
2, 3, 5, 7, 13, 71, 97, 397, 739, 99137, 139339, 1139917, 779919137, 97191997777319771, 3317719713399797917
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
Sequence in context: A055694 A249797 A346686 * A309249 A294727 A348352
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