%I #56 May 08 2021 07:47:13
%S 1,3,5,11,12,27,29,71,72,213,215,603,635,1917,1183893
%N Numbers k such that k^2 is a sum of distinct factorials.
%C a(16)^2 > 48! (about 1.24139*10^61), if it exists. - _Jon E. Schoenfield_, Aug 04 2006
%C A197183(a(n)) = 1. - _Reinhard Zumkeller_, Dec 04 2011
%C a(16) > 4.3*10^55 if it exists. - _Bert Dobbelaere_, Sep 16 2020
%D Posting by _Dan Hoey_ to math-fun mailing list.
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Factorial.html">Factorial</a>
%e 1183893^2 = 1! + 2! + 3! + 7! + 8! + 9! + 10! + 11! + 12! + 13! + 14! + 15!.
%e 2 is not a member since 4 is not a sum of distinct factorials.
%t ok[n_] := (k=1; ff={}; While[k! < n^2, AppendTo[ff, k!]; k++]; xx = Array[x, Length[ff]]; Reduce[And @@ (0 <= # <= 1 & /@ xx) && n^2 == xx.ff, xx, Integers] =!= False); ok[1] = True; Reap[Do[If[ok[n], Print[n]; Sow[n]], {n, 1, 2*10^6}]][[2, 1]] (* _Jean-François Alcover_, Jul 16 2012 *)
%o (Haskell)
%o import Data.List (elemIndices)
%o a014597 n = a014597_list !! (n-1)
%o a014597_list = tail $ elemIndices 1 $ map a197183 [0..]
%o -- _Reinhard Zumkeller_, Dec 04 2011
%o (Python)
%o from math import factorial, isqrt
%o from itertools import chain, combinations
%o from sympy.ntheory.primetest import is_square
%o fac =[factorial(n) for n in range(1, 16)] # raise 16 to search higher
%o def powerset(s): # skipping empty set
%o return chain.from_iterable(combinations(s, r) for r in range(1, len(s)+1))
%o gen = (isqrt(sum(s)) for s in powerset(fac) if is_square(sum(s)))
%o print(sorted(set(gen))) # _Michael S. Branicky_, Jan 03 2021
%Y Cf. A025494, A051761, A059589.
%K nonn,more,hard,nice
%O 1,2
%A _Eric W. Weisstein_
%E 15th term from _Jud McCranie_, who remarks that there no others involving terms < 21!.