login
Composite numbers for which both sum and product of digits are primes.
1

%I #13 May 24 2024 18:38:57

%S 12,21,115,511,1112,1121,1211,11711,13111,17111,31111,71111,111112,

%T 121111,211111,1111115,1111117,1111171,1111511,1115111,1151111,

%U 1511111,1711111,5111111,7111111,111111115,111111151,111111311,111111511,111115111,111131111,111151111

%N Composite numbers for which both sum and product of digits are primes.

%H Chai Wah Wu, <a href="/A225864/b225864.txt">Table of n, a(n) for n = 1..10000</a>

%t d[n_] := IntegerDigits[n]; t={}; Do[If[!PrimeQ[n] && PrimeQ[Plus@@(x=d[n])] && PrimeQ[Times@@x], AppendTo[t,n]], {n,2*10^6}]; t

%t Select[Range[72*10^5],CompositeQ[#]&&AllTrue[{Total[IntegerDigits[#]],Times@@ IntegerDigits[ #]},PrimeQ]&] (* The program generates the first 25 terms of the sequence. *) (* _Harvey P. Dale_, May 24 2024 *)

%o (Python)

%o from __future__ import division

%o from sympy import isprime

%o A225864_list = []

%o for l in range(1,20):

%o plist, q = [p for p in [2,3,5,7] if isprime(l-1+p)], (10**l-1)//9

%o for i in range(l):

%o for p in plist:

%o r = q+(p-1)*10**i

%o if not isprime(r):

%o A225864_list.append(r) # _Chai Wah Wu_, Aug 15 2017

%Y Cf. A046713, A225863.

%K nonn,base

%O 1,1

%A _Jayanta Basu_, May 18 2013

%E Extended by _T. D. Noe_, May 18 2013