OFFSET
1,1
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000 (first 718 terms from Marius A. Burtea)
EXAMPLE
2357 is a prime, each digit is a prime and the sum of digits = 17 is also a prime, so 2357 is a term.
MATHEMATICA
aQ[p_] := PrimeQ[p] && Module[{d = IntegerDigits[p]}, PrimeQ[Total[d]] && LengthWhile[d, PrimeQ[#] &] == Length[d]]; Select[Range[33000], aQ] (* Amiram Eldar, Dec 08 2018 *)
PROG
(PARI) isok(p) = isprime(p) && isprime(sumdigits(p)) && (#select(x->(! isprime(x)), digits(p)) == 0); \\ Michel Marcus, Dec 08 2018
(MATLAB)
prim=primes(1000000);
m=1;
for u=1:100;
v=prim(u);
nc=dec2base(v, 10)-'0';
s=sum(nc);
if and(isprime(nc)==1, isprime(s)==1)
sol(m)=v;
m=m+1;
end
end
sol; % Marius A. Burtea, Dec 08 2018
(Python)
from sympy import isprime
from itertools import count, islice, product
def agen():
yield from [2, 3, 5, 7]
for d in count(2):
for left in product("2357", repeat=d-1):
for end in "37":
ts = "".join(left) + end
if isprime(sum(map(int, ts))):
t = int(ts)
if isprime(t): yield t
print(list(islice(agen(), 46))) # Michael S. Branicky, Sep 23 2022
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Amarnath Murthy, Jun 16 2001
EXTENSIONS
Corrected and extended by Larry Reeves (larryr(AT)acm.org), Jun 21 2001
STATUS
approved