A356824 Palindromes that can be written as the sum of two palindromic primes.
4, 5, 6, 7, 8, 9, 22, 202, 232, 252, 262, 282, 292, 414, 444, 454, 464, 474, 484, 494, 626, 666, 686, 696, 808, 828, 858, 878, 888, 898, 20002, 20602, 20802, 20902, 21612, 21712, 21812, 21912, 22622, 22722, 22822, 22922, 23632, 23732, 23832, 23932, 24642, 24742, 24842, 24942
Offset: 1
Examples
282 can be written as the sum of two prime palindromes, 101 and 181. Thus, 282 is in the sequence.
Programs
-
Mathematica
q := Select[Range[30000], PalindromeQ[#] && PrimeQ[#] &] Select[Union[Flatten[Table[q[[n]] + q[[m]], {n, Length[q]}, {m, Length[q]}]]], PalindromeQ[#] &]
-
Python
from sympy import isprime from itertools import product def ispal(n): s = str(n); return s == s[::-1] def oddpals(d): # generator of odd palindromes with d digits if d == 1: yield from [1, 3, 5, 7, 9]; return for first in "13579": for p in product("0123456789", repeat=(d-2)//2): left = "".join(p); right = left[::-1] for mid in [[""], "0123456789"][d%2]: yield int(first + left + mid + right + first) def auptod(dd): N, alst, pp = 10**dd, [], [2, 3, 5, 7, 11] pp += [p for d in range(3, dd+1, 2) for p in oddpals(d) if isprime(p)] return sorted(set(p+q for p in pp for q in pp if p+q
Michael S. Branicky, Aug 29 2022
Comments