A173688 Numbers m such that the sum of square of factorial of decimal digits is prime.
10, 11, 12, 13, 14, 15, 19, 20, 21, 30, 31, 40, 41, 50, 51, 90, 91, 100, 101, 110, 111, 123, 132, 133, 134, 135, 138, 143, 144, 147, 153, 156, 158, 165, 168, 169, 174, 177, 183, 185, 186, 196, 203, 213, 230, 231, 302, 303, 304, 305, 308, 312, 313, 314, 315, 318, 320
Offset: 1
Examples
a(5) = 14 is in the sequence because (1!)^2 + (4!)^2 = 1 + 24^2 = 577 and 577 is prime.
Links
- Jinyuan Wang, Table of n, a(n) for n = 1..6821
Programs
-
Maple
with(numtheory):for n from 1 to 500 do:l:=length(n):n0:=n:s:=0:for m from 1 to l do:q:=n0:u:=irem(q,10):v:=iquo(q,10):n0:=v :s:=s+(u!)^2:od: if type(s,prime)=true then printf(`%d, `,n):else fi:od:
-
Mathematica
Select[Range[400],PrimeQ[Total[(IntegerDigits[#]!)^2]]&] (* Harvey P. Dale, Mar 23 2011 *)
-
Python
from itertools import count, islice, combinations_with_replacement from math import factorial from sympy import isprime from sympy.utilities.iterables import multiset_permutations def A173688_gen(): # generator of terms for l in count(0): for i in range(1,10): fi = factorial(i)**2 yield from sorted(int(str(i)+''.join(map(str,k))) for j in combinations_with_replacement(range(10), l) for k in multiset_permutations(j) if isprime(fi+sum(map(lambda n:factorial(n)**2,j)))) A173688_list = list(islice(A173688_gen(),50)) # Chai Wah Wu, Feb 23 2023
Comments