A227217 Primes p such that p + (product of digits of p) is prime and p - (product of digits of p) is prime.
23, 29, 83, 101, 103, 107, 109, 293, 307, 347, 349, 401, 409, 431, 439, 503, 509, 601, 607, 653, 659, 677, 701, 709, 743, 809, 907, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1123, 1201, 1297, 1301, 1303, 1307, 1409, 1423, 1489, 1523
Offset: 1
Examples
431 is prime, 431 + (4*3*1) = 443 is prime, and 431 - (4*3*1) = 419 is prime. So, 431 is a term in the sequence.
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10000
Programs
-
Maple
filter:= proc(n) local m; if not isprime(n) then return false fi; m:= convert(convert(n,base,10),`*`); if m = 0 then return true fi; isprime(n+m) and isprime(n-m) end proc: select(filter, [seq(2*i+1,i=5..10000)]); # Robert Israel, Apr 13 2015
-
Mathematica
fQ[n_] := Block[{d = IntegerDigits@ n}, PrimeQ[n + Times @@ d] && PrimeQ[n - Times @@ d]]; Select[Prime@ Range@ 250, fQ] (* Michael De Vlieger, Apr 12 2015 *)
-
PARI
forprime(p=1,2000,d=digits(p);P=prod(i=1,#d,d[i]);if(isprime(p+P)&&isprime(p-P),print1(p,", "))) \\ Derek Orr, Apr 10 2015
-
Python
from sympy import isprime, primerange def DP(n): p = 1 for i in str(n): p *= int(i) return p for pn in primerange(1, 2000): dpn = DP(pn) if isprime(pn-dpn) and isprime(pn+dpn): print(pn, end=', ') # Simplified by Derek Orr, Apr 10 2015
-
Sage
[p for p in primes_first_n(1000) if ((p-prod(Integer(p).digits(base=10))) in Primes() and (p+prod(Integer(p).digits(base=10))) in Primes())] # Tom Edgar, Sep 19 2013
Extensions
More terms from Derek Orr, Apr 10 2015
Comments