login
Primes p whose digit sum s(p) is also prime but whose iterated digit sum s(s(p)) is not prime.
5

%I #18 Feb 04 2021 05:49:34

%S 67,89,139,157,179,193,197,199,229,269,283,337,359,373,379,397,409,

%T 449,463,467,487,557,571,577,593,607,643,647,661,683,719,733,739,751,

%U 757,773,809,823,827,829,863,881,883,919,937,953,971,991,1039,1093,1097,1129,1187

%N Primes p whose digit sum s(p) is also prime but whose iterated digit sum s(s(p)) is not prime.

%C A046704 is primes p with s(p) also prime. A207294 is primes p with s(p) and s(s(p)) also prime. A070027 is primes p with all s(p), s(s(p)), s(s(s(p))), ... also prime. A104213 is primes p with s(p) not prime. A213354 is primes p with s(p) and s(s(p)) also prime but s(s(s(p))) not prime. A213355 is smallest prime p whose k-fold digit sum s(s(..s(p)).)..)) is also prime for all k < n, but not for k = n.

%H Charles R Greathouse IV, <a href="/A207293/b207293.txt">Table of n, a(n) for n = 1..10000</a>

%e 67 is prime and s(67) = 6+7 = 13 is also prime, but s(s(67)) = s(13) = 1+3 = 4 is not prime. Since no smaller prime has this property, a(1) = 67.

%p isA207293 := proc(n)

%p local d;

%p if isprime(n) then

%p d := digsum(n) ;

%p if isprime(d) then

%p d := digsum(d) ;

%p if isprime(d) then

%p false ;

%p else

%p true ;

%p end if;

%p else

%p false ;

%p end if;

%p else

%p false;

%p end if;

%p end proc:

%p A207293 := proc(n)

%p option remember ;

%p if n = 1 then

%p 67 ;

%p else

%p a := nextprime(procname(n-1)) ;

%p while not isA207293(a) do

%p a := nextprime(a) ;

%p end do:

%p a ;

%p end if;

%p end proc: # _R. J. Mathar_, Feb 04 2021

%t Select[Prime[Range[300]],

%t PrimeQ[Apply[Plus, IntegerDigits[#]]] && !

%t PrimeQ[Apply[Plus, IntegerDigits[Apply[Plus, IntegerDigits[#]]]]] &]

%t idsQ[n_]:=PrimeQ[Rest[NestList[Total[IntegerDigits[#]]&,n,2]]]=={True,False}; Select[Prime[Range[200]],idsQ] (* _Harvey P. Dale_, Dec 28 2013 *)

%o (PARI) select(p->my(s=sumdigits(p));isprime(s)&&!isprime(sumdigits(s)), primes(1000)) \\ _Charles R Greathouse IV_, Jun 10 2012

%Y Cf. A046704, A070027, A104213, A207294, A213354, A213355.

%K base,nonn

%O 1,1

%A _Jonathan Sondow_, Jun 09 2012