login
Primes that yield another prime if one adds either the sum of its digits or the product of its digits.
1

%I #10 Jul 12 2017 03:22:07

%S 101,103,163,233,293,307,431,499,509,563,617,701,743,1009,1049,1061,

%T 1087,1409,1423,1483,1489,1601,1607,1801,1867,2017,2039,2053,2273,

%U 2543,2633,2903,3041,3067,3089,3449,3607,4013,4057,4079,4211,4217,4273,4507

%N Primes that yield another prime if one adds either the sum of its digits or the product of its digits.

%H Robert Israel, <a href="/A128717/b128717.txt">Table of n, a(n) for n = 1..10000</a>

%e 163 + (1+6+3) = 173, 163 + 1*6*3 = 181; 173 and 181 are prime numbers.

%p filter:= proc(n) local S;

%p S:= convert(n,base,10);

%p isprime(n+convert(S,`+`)) and isprime(n+convert(S,`*`))

%p end proc:

%p A:= NULL:

%p p:= 2:

%p while p < 10000 do

%p if filter(p) then A:= A, p fi;

%p p:= nextprime(p)

%p od:

%p A; # _Robert Israel_, Jul 12 2017

%t Select[Prime[Range[500]], PrimeQ[ # + Plus @@ IntegerDigits[ # ]] && PrimeQ[ # + Times @@ IntegerDigits[ # ]] &]

%o (PARI) isok(n) = isprime(n) && (isprime(n+sumdigits(n)) && ((d=digits(n)) && isprime(n+prod(k=1, #d, d[k])))); \\ _Michel Marcus_, Jul 12 2017

%Y Cf. A048519.

%K base,easy,nonn

%O 1,1

%A _J. M. Bergot_, Jun 27 2007

%E Edited, corrected and extended by _Stefan Steinerberger_, Jul 14 2007