login
A351622
Palindromic primes (palprimes) whose sum of factorials of digits is also a palprime.
1
2, 11, 101, 1221221, 112111211, 121111121, 144010441, 335414533, 12444144421, 14244144241, 15525152551, 34254145243, 1034450544301, 1044141414401, 1044531354401, 1045341435401, 1053441443501, 1054341434501, 1054431344501, 1055050505501, 1055150515501, 1055500055501, 1104440444011
OFFSET
1,1
COMMENTS
a(n) has an odd number of digits with the middle digit is 0 or 1 except for the terms 2 and 11. - David A. Corneth, May 05 2022
REFERENCES
1221221 is a term because 1!+2!+2!+1!+2!+2!+1! = 11.
LINKS
PROG
(PARI) forprime(i=1, 10^12, di=digits(i); if(di==Vecrev(di), s=sum(j=1, #di, di[j]!); ds=digits(s); if(isprime(s) && ds==Vecrev(ds), print1(i, ", "))))
(Python)
from math import factorial
from sympy import isprime
from itertools import count, islice, product
myfact = {d:factorial(int(d)) for d in "0123456789"}
def ispal(s): return s == s[::-1]
def sofod(s): return sum(myfact[d] for d in s)
def palprimecandstrs():
yield from ["2", "3", "5", "7", "11"]
for digs in count(3, step=2):
for last in "1379":
for p in product("0123456789", repeat=digs//2-1):
left = "".join(p)
for mid in "01": # else sofod even (cf. Corneth comment)
yield last + left + mid + left[::-1] + last
def agen(): # generator of terms
for strp in palprimecandstrs():
s = sofod(strp)
if ispal(str(s)) and isprime(s):
p = int(strp)
if isprime(p):
yield p
print(list(islice(agen(), 23))) # Michael S. Branicky, May 13 2022
CROSSREFS
Subsequence of A002385.
Cf. A061602.
Sequence in context: A069664 A130150 A115941 * A024721 A367852 A285199
KEYWORD
nonn,base
AUTHOR
Alexandru Petrescu, May 05 2022
EXTENSIONS
More terms from David A. Corneth, May 06 2022
STATUS
approved