A110028 Primes with a prime number of digits, all of them prime, that add up to a prime.
23, 223, 227, 337, 353, 373, 557, 577, 733, 757, 773, 22573, 23327, 25237, 25253, 25523, 27253, 27527, 32233, 32237, 32257, 32323, 32327, 33223, 33353, 33377, 33533, 33773, 35227, 35353, 35533, 35537, 35573, 35753, 37223, 37337, 52237, 52253, 52727, 53353
Offset: 1
Examples
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.
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10000
Programs
-
Maple
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
-
Mathematica
Select[Prime@ Range@ 6000, And[PrimeQ@ Length@ #, AllTrue[#, PrimeQ], PrimeQ@ Total@ #] &@ IntegerDigits@ # &] (* or *) 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 *)
-
Python
from sympy import isprime, nextprime from itertools import islice, product def agen(): # generator of terms p = 2 while True: for d in product("2357", repeat=p-1): for last in "37": if isprime(sum(map(int, s:="".join(d) + last))): if isprime(t:=int(s)): yield t p = nextprime(p) print(list(islice(agen(), 40))) # Michael S. Branicky, May 26 2023
Comments