OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(5)=1553 since 1553+(1^2+5^2+5^2+3^2)=1553+60=1613 is a prime AND 1553-(1^2+5^2+5^2+3^2)=1553-60=1493 is a prime again.
MAPLE
filter:= proc(p) local t, r;
if not isprime(p) then return false fi;
r:= add(t^2, t=convert(p, base, 10));
isprime(p+r) and isprime(p-r);
end proc:
select(filter, [seq(i, i=3..20000, 2)]); # Robert Israel, Mar 30 2021
MATHEMATICA
Select[Prime[Range[2100]], AllTrue[#+{Total[IntegerDigits[#]^2], -Total[ IntegerDigits[ #]^2]}, PrimeQ]&] (* Harvey P. Dale, Aug 07 2021 *)
PROG
(PARI) sumdd(n) = {digs = digits(n, 10); return (sum(i=1, #digs, digs[i]^2)); }
lista(nn) = {forprime(p=2, nn, s = sumdd(p); if (isprime(p+s) && isprime(p-s), print1(p, ", ")); ); } \\ Michel Marcus, Jul 25 2013
(Python)
from sympy import isprime, primerange
def sumdd(n): return sum(int(d)**2 for d in str(n))
def list(nn):
for p in primerange(2, nn+1):
s = sumdd(p)
if isprime(p-s) and isprime(p+s): print(p, end=", ")
list(18133) # Michael S. Branicky, Mar 30 2021 after Michel Marcus
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Carmine Suriano, Jul 19 2010
STATUS
approved