%I #27 Nov 24 2021 03:06:59
%S 11,23,41,61,83,101,113,131,137,173,179,191,197,199,223,229,311,313,
%T 317,331,337,353,373,379,397,401,409,443,449,461,463,467,601,641,643,
%U 647,661,683,719,733,739,773,797,829,863,883,911,919,937,971,977,991,997,1013
%N Primes such that the sum of the squares of their digits is also a prime.
%C Primes p such that the sum of the squared digits of p is a prime q. For the values of q see A109181.
%D Clifford A. Pickover, A Passion for Mathematics, John Wiley & Sons, Inc., 2005, p. 89.
%D Charles W. Trigg, Journal of Recreational Mathematics, Vol. 20(2), 1988.
%H Zak Seidov, <a href="/A052034/b052034.txt">Table of n, a(n) for n = 1..10000</a>
%H Mike Mudge, <a href="https://archive.org/details/PersonalComputerWorldMagazine/PCW%20199705%20May%20Created%20From%20PCW%20Cover%20CD/page/n121/mode/1up?view=theater">Morph code</a>, Hands On Numbers Count, Personal Computer World, May 1997, p. 290.
%e p = 23 is in the sequence because q = 2^2 + 3^2 = 13 is a prime.
%e 9431 -> 9^2 + 4^2 + 3^2 + 1^2 = 107 (which is prime).
%p a:=proc(n) local nn, L: nn:=convert(n,base,10): L:=nops(nn): if isprime(n)= true and isprime(add(nn[j]^2,j=1..L))=true then n else end if end proc: seq(a(n),n=1..1000); # _Emeric Deutsch_, Jan 08 2008
%t Select[Prime[Range[250]],PrimeQ[Total[IntegerDigits[#]^2]]&] (* _Harvey P. Dale_, Dec 19 2010 *)
%o (Python)
%o from sympy import isprime, primerange
%o def ok(p): return isprime(sum(int(d)**2 for d in str(p)))
%o def aupto(limit): return [p for p in primerange(1, limit+1) if ok(p)]
%o print(aupto(1013)) # _Michael S. Branicky_, Nov 23 2021
%Y Cf. A003132, A052035, A091367, A108662, A109181.
%K nonn,base
%O 1,1
%A _Patrick De Geest_, Dec 15 1999
%E Edited by _N. J. A. Sloane_, Dec 15 2007 and again on Dec 05 2008 at the suggestion of _Zak Seidov_
|