# Summing of factorials to produce perfect cubes

I was playing around with factorials the other day, and I realized that $4!+5!$ is a perfect square. Perplexed by this result, I started looking for other pairs of factorials that produce a perfect square when added together (unbeknownst to me, I had stumbled across a well-known open problem in number theory). I could only find three: $1!+4!$, $1!+5!$, and $1!+7!$. Since $4!+5!$ seemed like an outlier, I decided to focus on the three which satisfy the formula $n!+1=m^2$. I turned to the main Math.SE chatroom, asking if there were any more, which is when I was informed that this is called Brocard's problem. Since it's a well-known open problem, I decided to put my own spin on it. It has probably been done before, but I can't find anything online.

What about the equation $n!+1=m^3$? As far as I know, there is no pair of integers that satisfies this equation. What if the conditions are relaxed? This brings me to the following question I came up with yesterday:

How many perfect cubes can be expressed as the sum of two or more unique integer factorials without subtractions, divisions, or multiplications of factorials?

Notice I said unique, meaning any factorial cannot appear more than once in a sum. With that in mind, I've only found three:\begin{align}&2!+3!=8=2^3\\&1!+2!+4!=27=3^3\;\;\;\Bbb{and}\\&1!+2!+3!+6!=729=9^3\,.\end{align}Are there more solutions, or are these the only three?

Using this link, I've concluded any additional solution must have the factorials add up to be greater than $341^3$. Since I hardly have any experience with programming, I can't go much further on this problem... Any and all help would be greatly appreciated.

Note: My question is NOT a duplicate of this one. I'm not restricting my problem to the partial sums $S_n$ of the series $\displaystyle \sum_{k=1}^nk!$.

• As you insist on distinct factorials, some simple bounds say that we can find the possible expressions of any target number $T$ as the sum of factorials with a greedy algorithm. Make a list of all numbers for, say, $0$ to $719$ that can be written as the sum of distinct factorials. For any target larger than $719,$ simply subtract off the largest factorial less than or equal than what you currently have, until you get to $719$ or smaller and can just look it up. As a result, I expect many more examples. There are also other programming methods. – Will Jagy Dec 13 '14 at 18:25
• @WillJagy Crap, I forgot to add that only positive integer factorials are allowed, and no subtraction is allowed... – teadawg1337 Dec 13 '14 at 18:35
• For example, $1!+2!+3!+4!+5!+6!+7!+8!$ is allowed. However, none of those may be repeated in the summand. The right side of the equation cannot be changed, it is always a fixed integer $n^3$. The problem with my constraints is that there's only a certain range of numbers that can be produced with each additional factorial... – teadawg1337 Dec 13 '14 at 18:59
• I feel that it's important to also point out that I didn't use any programming to find any of the solutions above, I know absolutely nothing about programming in any language. Unless LaTeX counts, in which case I'm somewhat decent – teadawg1337 Dec 13 '14 at 19:22

EDIT: Wrote a command to do sum of distinct factorials by greedy algorithm; here are the perfect powers I have, not allowing $0!$.

jagy@phobeusjunior:~$./greedy_factorial Sat Dec 13 12:25:29 PST 2014 0 1 1 8 3 2 9 3 2 1 25 4 1 27 4 2 1 32 4 3 2 121 5 1 128 5 3 2 144 5 4 729 6 3 2 1 841 6 5 1 5041 7 1 5184 7 5 4 45369 8 7 3 2 1 46225 8 7 6 5 4 1 363609 9 6 3 2 1 403225 9 8 4 1 3674889 10 8 7 6 3 2 1 1401602635449 15 14 13 12 11 10 9 8 7 3 2 1 Sat Dec 13 12:26:23 PST 2014  Did not get any more cubes yet. jagy@phobeusjunior:~$ ./greedy_factorial
0   square root    0 =
1   square root    1 =  1
8 = 2^3
9   square root    3 = 3
25   square root    5 = 5
27 = 3^3
32 = 2^5
121   square root    11 = 11
128 = 2^7
144   square root    12 = 2^2 3
729   square root    27 = 3^3
841   square root    29 = 29
5041   square root    71 = 71
5184   square root    72 = 2^3 3^2
45369   square root    213 = 3 71
46225   square root    215 = 5 43
363609   square root    603 = 3^2 67
403225   square root    635 = 5 127
3674889   square root    1917 = 3^3 71
1401602635449   square root    1183893 = 3 394631


Allowing $0!$ adds in the square $4,$ I'm not sure i see any other change. Not sure why the program is so very slow. As I said, if all you want is cubes, you can program in a greedy algorithm which, for each cube, will rapidly attempt a decomposition as distinct factorials (with repeat 1 for $0!$ if you wish ) and report success.

ALLOWING 0! = 1  ***+++***
jagy@phobeusjunior:~$./greedy_factorial Sat Dec 13 11:46:03 PST 2014 0 eleventh root 0 1 eleventh root 1 4 square root 2 8 cube root 2 9 square root 3 25 square root 5 27 cube root 3 32 fifth root 2 121 square root 11 128 seventh root 2 144 square root 12 729 cube root 9 841 square root 29 5041 square root 71 5184 square root 72 45369 square root 213 46225 square root 215 363609 square root 603 403225 square root 635 3674889 square root 1917 1401602635449 square root 1183893 Sat Dec 13 11:46:36 PST 2014 jagy@phobeusjunior:~$

• Does allowing $0!$ change anything? – teadawg1337 Dec 13 '14 at 19:17
• Hmm.... I'll write a program tomorrow, I've gotta call it a day even though it's only 2 in the afternoon (I'm sick and exhausted as heck) – teadawg1337 Dec 13 '14 at 19:57
• @WillJagy: Apologies about the very minor edit. The reason for it is that I had inadvertently downvoted instead of upvoting. Touchscreen, it has happened more than once. By the time I noticed, it could not be reversed unless the thing was edited. – André Nicolas Dec 14 '14 at 7:32
• The most intriguing part about this problem, imo, is that it seems to only have three solutions, just like Brocard's problem... There's most likely more solutions to my variant, but I only have a mediocre gaming rig with a 2.8 GHz processor (not enough computing power)... Also, given the relatively HUGE gap between the last two square roots, any further solutions are likely to take a lot of computing time as well... – teadawg1337 Dec 14 '14 at 15:13
• @Andre, thanks. – Will Jagy Dec 14 '14 at 18:16

This is just a comment, but notice that if $a_{1} < a_{2} < \ldots < a_{n}$, then $a_{1}! + a_{2}! + \ldots + a_{m}!$ is divisible by $a_{1}!$, and if $a_{2} > a_{1} + 1$ if $a_{1}$ is even or $a_{2} > a_{1}$ if $a_{1}$ is odd, then each $a_{j}!$ is divisible by a higher power of $2$ than $a_{1}!$ is for each $j > 1.$ In either of these cases, the highest power of $2$ dividing $a_{1}!$ is an integer multiple of $3$ ( though possibly zero, which happens only when $a_{1} = 1$). This puts constraints on $a_{1}$ when $a_{2} > a_{1}+1.$ It's possible to argue similarly for other primes $p \leq a_{1}$ when there is an integer multiple of $p$ between $a_{1}$ and $a_{2}$ (including $a_{2}$ itself)- where we obtain that the sum of the digits in the $p$-adic expansion of $a_{1}$ is a multiple of $p-1.$ However, I can't see this approach alone being sufficient to answer the question ( it is no help when $a_{1} = 1$, for example. On the other hand, when $a_{1} = 2,$ it forces $a_{2} = 3$, and if we try to find a longer example with $a_{1}= 2$ and $a_{2} = 3$ we find it impossible).