A052035 Palindromic primes whose sum of squared digits is also prime.
11, 101, 131, 191, 313, 353, 373, 797, 919, 10301, 11311, 12721, 13331, 13931, 14341, 14741, 16361, 17971, 18181, 19391, 30103, 30703, 33533, 71317, 71917, 74747, 75557, 76367, 77977, 79397, 90709, 93139, 93739, 95959, 96769, 97379
Offset: 1
Examples
373 -> 3^2 + 7^2 + 3^2 = 67, which is prime.
References
- Charles W. Trigg, Journal of Recreational Mathematics, Vol. 20(2), 1988.
Links
- Michel Marcus, Table of n, a(n) for n = 1..1215
- Mike Mudge, Morph code, Hands On Numbers Count, Personal Computer World, May 1997, p. 290.
Programs
-
Mathematica
Select[Prime@ Range[2, 10^4], And[PalindromeQ@ #, PrimeQ@ Total[IntegerDigits[#]^2]] &] (* Michael De Vlieger, Oct 20 2021 *)
-
PARI
isok(p) = my(d=digits(p)); isprime(p) && (d==Vecrev(d)) && isprime(sum(k=1, #d, d[k]^2)); \\ Michel Marcus, Oct 17 2021
-
Python
from sympy import isprime def ok(n): s = str(n) return s==s[::-1] and isprime(n) and isprime(sum(int(d)**2 for d in s)) print([k for k in range(10**5) if ok(k)]) # Michael S. Branicky, Nov 23 2021
-
Python
# second version for going to large terms from sympy import isprime from itertools import product def ok(pal): return isprime(pal) and isprime(sum(int(d)**2 for d in str(pal))) def agentod(maxdigs): yield 11 for d in range(3, maxdigs+1, 2): pal = 10**(d-1) + 1 if ok(pal): yield pal for first in "1379": for left in product("0123456789", repeat=(d-3)//2): left = "".join(left) for mid in "13579": pal = int(first + left + mid + left[::-1] + first) if ok(pal): yield pal print([an for an in agentod(5)]) # Michael S. Branicky, Nov 23 2021
Comments