login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Smallest prime p such that the sum of the squares of the digits of p equals n (or 0 if no such prime exists).
0

%I #13 Mar 30 2012 18:35:54

%S 0,11,0,2,101111,211,2111,101111111,3,13,113,112121,23,21221,1123,

%T 11213,41,1223,313,10133,241,233,112223,21313,5,431,151,1151,13313,

%U 251,2333,11251,2243,53,1433,1153,61,523,1523,11161,443,541,353,33413,2621,163,1163,13523,7,17

%N Smallest prime p such that the sum of the squares of the digits of p equals n (or 0 if no such prime exists).

%C a(3) = 0 because the numbers of the form 10..010..01 are divisible by 3. Conjecture : except for the numbers 1 and 3, for every possible square digit sum there exists a prime.

%e a(13) = 23 because 2^2 + 3^2 = 13, and 23 is the least such prime.

%p with(numtheory):for k from 2 to 100 do: id:=0:for p from 1 to 100000 while(id=0)

%p do:n:=ithprime(p):l:=length(n):n0:=n:s:=0:for m from 1 to l do:q:=n0:u:=irem(q,10):v:=iquo(q,10):n0:=v :s:=s+u^2:od: if s=k then id:=1:printf(`%d, `,n):else fi:od:od:

%Y Cf. A003132, A020449, A055016, A067180.

%K nonn,base

%O 1,2

%A _Michel Lagneau_, Mar 26 2011