login
Emirps p such that p + (sum of digits of p) is an emirp.
2

%I #11 Jan 25 2021 19:02:58

%S 13,71,97,701,1061,1223,1597,1847,1933,3067,3089,3373,3391,3889,7027,

%T 7043,7577,9001,9241,9421,10061,10151,10333,10867,11057,11657,11677,

%U 11897,11923,12227,12269,12809,13147,13457,13477,14087,14207,16979,17011,17033,17903,32173,32203,32353,32687,33589

%N Emirps p such that p + (sum of digits of p) is an emirp.

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

%e a(3) = 97 is an emirp because 97 and 79 are distinct primes. Its sum of digits is 9+7=16, and 97+16 = 113 is an emirp because 113 and 311 are primes.

%p revdigs:= proc(n) local L,i;

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

%p add(10^(i-1)*L[-i],i=1..nops(L))

%p end proc:

%p isemirp:= proc(n) local r;

%p if not isprime(n) then return false fi;

%p r:= revdigs(n);

%p r <> n and isprime(r)

%p end proc:

%p filter:= n -> isemirp(n) and isemirp(n +convert(convert(n,base,10),`+`)):

%p select(filter, [seq(i,i=3..10^5,2)]);

%o (Python)

%o from sympy import isprime

%o def sd(n): return sum(map(int, str(n)))

%o def emirp(n):

%o if not isprime(n): return False

%o revn = int(str(n)[::-1])

%o if n == revn: return False

%o return isprime(revn)

%o def ok(n): return emirp(n) and emirp(n + sd(n))

%o def aupto(nn): return [m for m in range(1, nn+1) if ok(m)]

%o print(aupto(18000)) # _Michael S. Branicky_, Jan 24 2021

%Y Cf. A006567. Contains A340843.

%K nonn,base

%O 1,1

%A _J. M. Bergot_ and _Robert Israel_, Jan 23 2021