A358998 Nonprimes whose sum of factorials of digits is a prime.
10, 12, 20, 21, 30, 100, 110, 111, 122, 133, 134, 135, 136, 143, 153, 155, 178, 187, 202, 212, 220, 221, 303, 304, 305, 306, 314, 315, 316, 330, 340, 341, 350, 351, 360, 361, 403, 413, 430, 505, 513, 515, 530, 531, 550, 551, 603, 630, 708, 718, 780, 781, 807
Offset: 1
Examples
134 is in the sequence because it is not prime and 1! + 3! + 4! = 1 + 6 + 24 = 31 which is a prime number. 202 is also in the sequence because it is not prime and 2! + 0! + 2! = 5 prime.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..10000
Crossrefs
Programs
-
Mathematica
Select[Range[1000], ! PrimeQ[#] && PrimeQ[Total[IntegerDigits[#]!]] &] (* Amiram Eldar, Feb 11 2023 *)
-
Python
from sympy import isprime from math import factorial S=[] nomb=200 i=0 while len(S) < nomb: i+=1 if isprime(i): continue som=0 for j in range(len(str(i))): som+=factorial(int(ix[j])) if not isprime(som): continue S.append(i)
-
Python
from sympy import isprime from math import factorial def f(n): return sum(factorial(int(d)) for d in str(n)) def ok(n): return not isprime(n) and isprime(f(n)) print([k for k in range(900) if ok(k)]) # Michael S. Branicky, Feb 11 2023