login
A065439
Numbers n such that s[n], p[n] and s[n]+p[n] are all prime numbers, where s[n] is the sum of digits of n and p[n] is the product of digits of n.
1
12, 21, 1112, 1121, 1211, 2111, 1111111112, 1111111121, 1111111211, 1111112111, 1111121111, 1111211111, 1112111111, 1121111111, 1211111111, 2111111111, 1111111111111112, 1111111111111121, 1111111111111211, 1111111111112111
OFFSET
1,1
COMMENTS
p[n] will always be 2 and s[n] and s[n]+p[n] will always be twin primes.
It is therefore hugely more efficient to search for terms by looking at permutations of any given number of ones together with one two. In addition, it is more efficient not to compute or consider permutations of two together with 4, 7, 10, . . . 3n+1 ones because the sums of those digits are all multiples of 3 so the numbers cannot be primes. - Harvey P. Dale, Apr 27 2019
MATHEMATICA
Do[s = Apply[ Plus, IntegerDigits[n]]; p = Apply[ Times, IntegerDigits[n]]; If[ PrimeQ[s] && PrimeQ[p] && PrimeQ[s + p], Print[n]], {n, 1, 10^7} ]
spQ[n_]:=Module[{idn=IntegerDigits[n], s, p}, s=Total[idn]; p=Times@@idn; AllTrue[ {s, p, s+p}, PrimeQ]]; Table[Select[FromDigits/@Permutations[ Join[ {2}, PadRight[{}, n, 1]]], spQ], {n, Drop[Range[200], {0, -1, 3}]}]//Flatten//Sort (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Apr 27 2019 *)
CROSSREFS
Sequence in context: A292523 A162391 A114015 * A214218 A323084 A323083
KEYWORD
base,nonn
AUTHOR
Santi Spadaro, Nov 17 2001
EXTENSIONS
Comment and more terms from Larry Reeves (larryr(AT)acm.org), Nov 27 2001
STATUS
approved