%I #24 Feb 23 2023 12:04:35
%S 0,1,14,15,17,22,40,41,45,50,51,54,70,71,102,112,120,121,123,132,144,
%T 156,165,200,201,203,210,211,213,230,231,302,312,320,321,334,343,404,
%U 414,433,440,441,457,475,506,516,547,560,561,574,605,615,650,651,745,754,1000
%N Numbers m such that the sum of factorial of the decimal digits of m is square.
%C Let the decimal expansion of n = d(0)d(1)...d(p). Numbers such that Sum_{k=0..p} d(k)! is square.
%C Same as A130687 except for the additional 0. - _Georg Fischer_, Oct 12 2018
%H Jinyuan Wang, <a href="/A173687/b173687.txt">Table of n, a(n) for n = 1..9700</a>
%e 17 is in the sequence because 1! + 7! = 1 + 5040 = 71^2.
%p with(numtheory):for n from 0 to 1000 do:l:=length(n):n0:=n:s:=0:for m from
%p 1 to l do:q:=n0:u:=irem(q,10):v:=iquo(q,10):n0:=v :s:=s+u!:od: q:=sqrt(s):if
%p floor(q)= q then printf(`%d, `,n):else fi:od:~
%t Select[Range[0, 1000], IntegerQ[Sqrt[Total[IntegerDigits[#]!]]]&] (* _Jinyuan Wang_, Feb 26 2020 *)
%o (Magma) [ n: n in [0..1000] | n eq 0 or IsSquare(&+[ Factorial(d): d in Intseq(n) ]) ];
%o (Python)
%o from itertools import count, islice, combinations_with_replacement
%o from math import factorial
%o from sympy.ntheory.primetest import is_square
%o from sympy.utilities.iterables import multiset_permutations
%o def A173687_gen(): # generator of terms
%o yield 0
%o for l in count(0):
%o for i in range(1,10):
%o fi = factorial(i)
%o 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 is_square(fi+sum(map(factorial,j))))
%o A173687_list = list(islice(A173687_gen(),50)) # _Chai Wah Wu_, Feb 23 2023
%K nonn,base
%O 1,3
%A _Michel Lagneau_, Nov 25 2010
|