%I #20 May 26 2023 10:48:24
%S 23,223,227,337,353,373,557,577,733,757,773,22573,23327,25237,25253,
%T 25523,27253,27527,32233,32237,32257,32323,32327,33223,33353,33377,
%U 33533,33773,35227,35353,35533,35537,35573,35753,37223,37337,52237,52253,52727,53353
%N Primes with a prime number of digits, all of them prime, that add up to a prime.
%C First 7-digit number in this sequence is 2222333.
%C From _Michael De Vlieger_, Feb 02 2019: (Start)
%C First p-digit number in this sequence:
%C 2 23
%C 3 223
%C 5 22573
%C 7 2222333
%C 11 22222222223
%C 13 2222222225323
%C 17 22222222222225237
%C 19 2222222222222223527
%C 23 22222222222222222232723
%C 29 22222222222222222222222222577
%C 31 2222222222222222222222222232257
%C 37 2222222222222222222222222222222235773
%C ...
%C (End)
%H Michael De Vlieger, <a href="/A110028/b110028.txt">Table of n, a(n) for n = 1..10000</a>
%e 22573 is a term because 22573 is prime, it has five digits (5 is a prime), all digits (2,3,5,7) are prime, and the sum of the digits is 2+2+5+7+3 = 19, which is also a prime.
%p a:=proc(n) local nn: nn:=convert(n,base,10): if isprime(n) and isprime(nops(nn)) and map(isprime,nn)=[seq(true,i=1..nops(nn))] and isprime(add(nn[j],j=1..nops(nn))) then n fi end: seq(a(k),k=1..60000); # _Emeric Deutsch_, Apr 02 2006
%t Select[Prime@ Range@ 6000, And[PrimeQ@ Length@ #, AllTrue[#, PrimeQ], PrimeQ@ Total@ #] &@ IntegerDigits@ # &] (* or *)
%t With[{p = {2, 3, 5, 7}}, Table[Select[FromDigits /@ Select[Tuples[p, {q}], PrimeQ@ Total@ # &], PrimeQ], {q, Prime@ Range@ 3}]] // Flatten (* _Michael De Vlieger_, Feb 02 2019 *)
%o (Python)
%o from sympy import isprime, nextprime
%o from itertools import islice, product
%o def agen(): # generator of terms
%o p = 2
%o while True:
%o for d in product("2357", repeat=p-1):
%o for last in "37":
%o if isprime(sum(map(int, s:="".join(d) + last))):
%o if isprime(t:=int(s)):
%o yield t
%o p = nextprime(p)
%o print(list(islice(agen(), 40))) # _Michael S. Branicky_, May 26 2023
%Y Cf. A000040, A062088.
%K nonn,base
%O 1,1
%A _Sergio Pimentel_, Mar 31 2006
|