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.

A052035 Palindromic primes whose sum of squared digits is also prime.

Original entry on oeis.org

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

Views

Author

Patrick De Geest, Dec 15 1999

Keywords

Comments

From Bernard Schott, Oct 20 2021: (Start)
Except for 11, all terms have an odd number of digits.
Except for terms of the form 10^k+1, k >= 2, the middle digit is always odd; the unique known term of the form 10^k+1 for 2 <= k <= 100000 is 101 (see comment in A000533). (End)

Examples

			373 -> 3^2 + 7^2 + 3^2 = 67, which is prime.
		

References

  • Charles W. Trigg, Journal of Recreational Mathematics, Vol. 20(2), 1988.

Crossrefs

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