%I #8 Aug 10 2022 07:40:26
%S 7,17,5717,27175717,212717571727175717,
%T 8717571727175717212717571727175717,
%U 2327175717271757172127175717271757178717571727175717212717571727175717
%N Beginning with 7, distinct primes such that every partial concatenation is a palindrome.
%C From _Michael S. Branicky_, Aug 09 2022: (Start)
%C If terms were not required to be distinct, then 7, 7, 7, ... or 7, 17, 17, 17, ... satisfy the requirement.
%C a(11) has 1132 digits. (End)
%H Michael S. Branicky, <a href="/A113613/b113613.txt">Table of n, a(n) for n = 1..10</a>
%e 7, 717, 7175717, 717571727175717, ... are all palindromes.
%o (Python)
%o from sympy import isprime
%o from itertools import count, islice, product
%o def pals(digs):
%o yield from digs
%o for d in count(2):
%o for p in product(digs, repeat=d//2):
%o left = "".join(p)
%o for mid in [[""], digs][d%2]:
%o yield left + mid + left[::-1]
%o def folds(s): # generator of suffixes of palindromes starting with s
%o for i in range((len(s)+1)//2, len(s)+1):
%o for mid in [True, False]:
%o t = s[:i] + (s[:i-1][::-1] if mid else s[:i][::-1])
%o if t.startswith(s):
%o yield t[len(s):]
%o yield from ("".join(p)+s[::-1] for p in pals("0123456789"))
%o def agen():
%o s, seen = "7", {"7"}; yield 7
%o while True:
%o for t in folds(s):
%o if len(t) and t[0] != "0" and t not in seen and isprime(int(t)):
%o break
%o s += t; seen.add(t); yield int(t)
%o print(list(islice(agen(), 7))) # _Michael S. Branicky_, Aug 09 2022
%Y Cf. A113612.
%K base,nonn
%O 1,1
%A _Amarnath Murthy_, Nov 09 2005
%E Name clarified and a(5) and beyond from _Michael S. Branicky_, Aug 09 2022