cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A356824 Palindromes that can be written as the sum of two palindromic primes.

This page as a plain text file.
%I A356824 #17 Sep 04 2022 12:46:24
%S A356824 4,5,6,7,8,9,22,202,232,252,262,282,292,414,444,454,464,474,484,494,
%T A356824 626,666,686,696,808,828,858,878,888,898,20002,20602,20802,20902,
%U A356824 21612,21712,21812,21912,22622,22722,22822,22922,23632,23732,23832,23932,24642,24742,24842,24942
%N A356824 Palindromes that can be written as the sum of two palindromic primes.
%C A356824 With the exception of 22, which is the sum of 11 and 11, no term of this sequence has an even number of digits. Proof: Other than 11, palindromes with an even number of digits are not primes (since they are divisible by 11). Suppose m is a term of this sequence with 2k digits. Then m must be the sum of two palindromic primes p and q with 2k-1 digits each. It follows that the first and the last digit of m is 1. Hence, either p or q is even, creating a contradiction with primality.
%C A356824 With the exception of 5, 7, and 9, all terms of this sequence are even. Proof: two consecutive multi-digit palindromes differ by at least 10, so larger palindromes can't be the sum of a palindromic prime and 2. Thus, each multi-digit term is the sum of two odd numbers.
%e A356824 282 can be written as the sum of two prime palindromes, 101 and 181. Thus, 282 is in the sequence.
%t A356824 q := Select[Range[30000], PalindromeQ[#] && PrimeQ[#] &]
%t A356824 Select[Union[Flatten[Table[q[[n]] + q[[m]], {n, Length[q]}, {m, Length[q]}]]],
%t A356824 PalindromeQ[#] &]
%o A356824 (Python)
%o A356824 from sympy import isprime
%o A356824 from itertools import product
%o A356824 def ispal(n): s = str(n); return s == s[::-1]
%o A356824 def oddpals(d): # generator of odd palindromes with d digits
%o A356824     if d == 1: yield from [1, 3, 5, 7, 9]; return
%o A356824     for first in "13579":
%o A356824         for p in product("0123456789", repeat=(d-2)//2):
%o A356824             left = "".join(p); right = left[::-1]
%o A356824             for mid in [[""], "0123456789"][d%2]:
%o A356824                 yield int(first + left + mid + right + first)
%o A356824 def auptod(dd):
%o A356824     N, alst, pp = 10**dd, [], [2, 3, 5, 7, 11]
%o A356824     pp += [p for d in range(3, dd+1, 2) for p in oddpals(d) if isprime(p)]
%o A356824     return sorted(set(p+q for p in pp for q in pp if p+q<N and ispal(p+q)))
%o A356824 print(auptod(5)) # _Michael S. Branicky_, Aug 29 2022
%Y A356824 Cf. A002113, A002385, A261906.
%K A356824 nonn,base
%O A356824 1,1
%A A356824 _Tanya Khovanova_, Aug 29 2022