# Can $1!^2+2!^2+3!^2+\dots+n!^2$ be a perfect power when $n\geq2$?

I know that $$S_n:=1!^2+2!^2+3!^2+\dots+n!^2$$ cannot be a perfect square because it is equal to $$2\pmod{3}$$ and it is never a perfect cube because it is equal to $$5\pmod{9}$$, but can $$S_n$$ be a higher odd perfect power?

Edit:

• $$S_n$$ cannot be also a perfect 5th power when $$n\geq10$$, since $$17$$ is not a 5th power residue $$\pmod{100}$$.

• $$S_n$$ is also never a perfect 11th power if $$n\geq23$$, since $$8$$ is not a 11th power residue $$\pmod{23}$$.

• $$S_n$$ is not a perfect 7th power for all $$n\geq29$$ because $$7$$ is not a 7th power residue $$\pmod{29}$$.

• $$S_n$$ is not a perfect 13th power if $$n\geq52$$, since $$7$$ is not 13th power residue $$\pmod{53}$$.

• $$S_n$$ isn't a perfect 17th power when $$n\geq137$$, since $$70$$ is not a 17th power residue $$\pmod{137}$$.

• $$S_n$$ isn't a perfect 19th power when $$n\geq191$$, since $$44$$ is not 19th power residue $$\pmod{191}$$.

• $$S_n$$ is never a perfect 23rd power if $$n\geq47$$, since $$30$$ is not a 23rd power residue $$\pmod{47}$$.

• $$S_n$$ is not a perfect 29th power for all $$n\geq59$$, since $$5$$ is not 29th power residue $$\pmod{59}$$.

• If $$n\geq310$$, then $$S_n$$ is never a perfect 31st power, since $$62$$ is not a 31st power residue $$\pmod{311}$$.

• $$S_n$$ is not a perfect 37th power for all $$n\geq148$$, since $$88$$ isn't a 37th power residue $$\pmod{149}$$.

• $$S_n$$ cannot be a perfect 41st power for all $$n\geq82$$, because $$S_{82}\equiv45\pmod{83}$$, and since $$x^{41}\equiv45\pmod{83}$$ is not solvable, $$45$$ is not a 41st power residue $$\pmod{83}$$.

• For all $k$ even, we can easily see that $a^k$ will not leave remainder 2 when divided by 3, for any natural number $a$. And hence, $$1!^2+2!^2+\dots+n!^2$$ is never a $k^{th}$ power ($k$ being even). For all $k$, odd, again it can be easily seen that $a^k$ can never leave reminder 5 when divided by 9. Hence, the conclusion. Jun 3, 2023 at 16:58
• @YathirajSharma What is wrong with remainder $5$ mod $9$? For example $32^7$ is a perfect power that is $5$ mod $9$. Jun 3, 2023 at 17:05
• Oh yes. I missed a calculation for odd $k$. My cases for odd $k$ apply to those odds $k$ which are multiples of 3. Jun 3, 2023 at 17:10
• For positive integer $n\le 10^4$ , the sum is never a perfect power ($1$ not condsidered to be a perfect power). Jun 3, 2023 at 17:51
• @WillJagy Does this lead to the conjecture that the above sum is even squarefree for all positive integers $n$ ? Jun 3, 2023 at 21:51

Note that, for $$n\geq9$$, it is easy to show that $$S(n)$$ always has $$1817$$ as last digits. This fact eliminates the posibility of $$S(n)$$ being some even perfect power. For odd integers, note that:

• perfect powers of integers having $$1$$ as last digit also have $$1$$ as last digit, so $$S(n)$$ can not be a perfect power of some odd integer having $$1$$ as last digit.

• perfect powers of integers having $$3$$ as last digit have $$3,9,7,1$$ as last digits, so $$S(n)$$ could be a perfect power of some odd integer having $$3$$ as last digit only for powers $$P$$ of the form $$P^{4k+3}$$. It would remain to show that there is not any power of some odd integer having $$3$$ as last digit of the form $$P^{4k+3}$$ that could end in $$1817$$.

• perfect powers of integers having $$5$$ as last digit also have $$5$$ as last digit, so $$S(n)$$ can not be a perfect power of some odd integer having $$5$$ as last digit.

• perfect powers of integers having $$7$$ as last digit have $$7,9,3,1$$ as last digits, so $$S(n)$$ could be a perfect power of some odd integer having $$7$$ as last digit only for powers $$P$$ of the form $$P^{4k+1}$$. It would remain to show that there is not any power of some odd integer having $$7$$ as last digit of the form $$P^{4k+1}$$ that could end in $$1817$$.

• perfect powers of integers having $$9$$ as last digit have $$9,1$$ as last digits, so $$S(n)$$ can not be a perfect power of some odd integer having $$9$$ as last digit.

Indeed, the "fixed" last digits of $$S(n)$$ grow as $$n$$ grows, so if there exists a counterexample for the pending cases, maybe other ones with more fixed ending digits could work.

EDIT

Running a Python program, I have been checking all odd integers less than $$10001$$ having $$3$$ or $$7$$ as last digit, and powers of the form $$4k+3$$ or $$4k+1$$ respectively less than $$10001$$.

I have been able to check that there are both powers of odd integers having $$3$$ as last digit of the form $$P^{4k+3}$$, and powers of odd integers having $$7$$ as last digit of the form $$P^{4k+3}$$, that end in $$1817$$. For instance, $$73^{443}$$ or $$137^{57}$$, although the program showed at least fourteen counterexamples before I stopped it.

I have found the powers $$137^{2057}$$, $$153^{1399}$$, $$297^{929}$$, $$313^{1587}$$, and $$473^{2403}$$ before I stopped the program, all of them ending in $$51817$$, the last five digits of $$S(n)$$ for $$n\geq 14$$

I have found the power $$777^{653}$$ ending in $$851817$$, the last six digits of $$S(n)$$ for $$n\geq 14$$, before I stopped the program.

Therefore, although the suitable powers get scarcer, the "fixed" last digits approach does not seem so promising as it could, or at least some additional insight would be needed. It seems that the smallest powers ending in some given fixed digits of $$S(n)$$ are quite bigger than $$S(n)$$, so proving that this holds would be a possible line of attack.

EDIT 2

Noting that $$\lim_{n\to\infty} \frac{n!^2}{S(n)}=1$$, we have that $$S(n); hence, there is an important restriction on the size of the possible perfect powers. Proving a minimum size of the powers generating the "fixed" digits greater than $$n^{2n}$$ could be a way to solve the problem.

Note also that the number of "fixed" digits of $$S(n)$$ seems to be always near to $$\frac{n}{2}$$.

• A perfect even power is also a perfect square, so your second sentence is unnecessary given the OP. A number with last digit 5 is a multiple of 5, so your third bullet is likewise unnecessary. (I hope you see that the OP's focus on prime exponents is justified.) Jul 10, 2023 at 11:31
• @mr_e_man I think that a self-contained answer is always better, although you are right. Of course, I see what you say about prime exponents, I just have focused on another way to approach the question, pointing out that repetition and continuous increase of "fixed" ending digits of $S(n)$ as $n$ grows is an important fact that could lead eventually to an answer in negative terms of the question posed at the OP Jul 10, 2023 at 14:05
• For n > 100 the last digits are 362944395975863609110502747608704759517069851817 Jul 11, 2023 at 12:22

# A complete proof

First of all, $$1248829|S(n)$$ if $$n\geq 1248828$$ (as confirmed by this post and also by this link).

The question now arises, does $$1248829^2|S(n)$$ ever occur? If not we know that $$S(n)$$ will never be a perfect power if $$n \geq 1248828$$ as it has exactly one factor of $$1248829$$. To see that this can indeed never occur I will note that $$1248829^2|(k!)^2$$ if $$k\geq 1248829$$, thus, we only need to verify whether $$1248829^2|S(1248828)$$ holds. In fact we have $$S(1248828)\equiv869856854002 \pmod {1248829^2}$$, hence $$S(n)$$ will never be a perfect power if $$n \geq 1248828$$. (also, great work @mr_e_man for finding this)

For notation, let $$b^e=S(n)$$ denote the perfect power. This method is also adapted from one of the comments by mr_e_man.

First of all, I verified by brute force that $$n > 10^5$$.

Using $$\lambda = 2^7 3^3 5^2 7^1 11^1 13^1$$ and a modulus $$M=2^{7+2}3^{3+1}5^{2+1}7^211^213^2 \cdot m\approx 6.7 \cdot 10^{640}$$ with $$m$$ a product of all primes $$13 < p < 100000$$ such that for each prime $$p$$ dividing $$m$$ the factorization of $$p-1$$ is a divisor of $$\lambda$$ (note that $$S(n)\bmod M$$ is constant for $$n\geq 100000$$) I iterated through all integers $$0\leq e<\lambda$$ prime to $$\lambda$$ and calculated $$b\equiv S(1000000)^{(1/e \bmod \lambda)} \pmod M$$. The minimum of these values was $$b=1.76 \cdot 10^{632}$$. Hence $$b > 10^{632}$$. (for more information see the comment from mr_e_man).

From the OP, we know that a few perfect prime powers are impossible, I extended the search to all perfect (prime) powers up to $$e \geq 3167$$. That is, I found triples $$(x, y, z)$$ for all primes $$x < 3167$$ which fit into the sentence

Cannot be a perfect {x} power for all $$n\geq$${z} due to {y} not being a perfect {x} power modulo {z}.

The first of these triples are

[(2, 2, 3), (3, 3, 7), (5, 3, 11), (7, 9, 29), (11, 8, 23), (13, 7, 53),
(17, 43, 103), (19, 44, 191), (23, 30, 47), (29, 5, 59), (31, 62, 311),
(37, 88, 149), (41, 6, 83), (43, 87, 173), (47, 193, 283), (53, 3, 107),
(59, 534, 709), (61, 224, 367), (67, 244, 269), (71, 204, 569), (73, 288, 293),
(79, 234, 317), (83, 148, 167), (89, 7, 179), (97, 100, 389)]


Note that I kept $$z<10^5$$, as I only verified $$n$$ up to $$10^5$$. The first case for which $$z > 10^5$$ is the prime $$3167$$ (interestingly, most of these records of $$z$$ are listed in A233516).

Using the new lower bounds of $$b$$ and $$e$$, we get that $$b^e > 10^{2000000} > (204001!)^2 > S(204000)\,.$$ Without doing that much calculations we thus know that $$n > 204000$$. This gave a new minimum for $$e$$ as the triple $$(3167, 50827, 114013)$$ could now be found. In short: $$n > 100000 \implies b > 10^{632}, e \geq 3167 \implies n > 204000 \implies e \geq 3833 \implies \\ n > 244000 \implies e \geq 5227 \implies n > 325000 \implies$$ $$b > 1.589\cdot 10^{837} \textrm{(using \lambda'=2\lambda, p<325000, and M\approx 2.8 \cdot 10^{844})} \implies n > 420000 \implies$$ $$e \geq 6637 \implies n > 522000 \implies e \geq 12919 \implies \\ n > 950000 \implies e \geq 18637 \implies n > 1350000$$ concluding the proof.

Any verification/double check is welcome.

# Another try to prove it which failed.

This reasoning is an adaptation of @JuanMoreno's answer, but it extended to multiple modulos.

First, define $$M=160$$ to be our modulo, we have that $$S(n) \equiv 137 \pmod M$$ if $$n \geq 4$$. Also, if for all integers $$0 \leq a < M$$ we check whether $$a^i \equiv 137 \pmod M$$ holds for some integer $$0 \leq i < \varphi(M)$$ we get that $$a = 137$$ or $$a = 153$$ must hold. This implies that we must have $$b \equiv 137,153 \pmod {160}$$ since only then $$b^e \equiv S(n) \equiv 137 \pmod {160}$$ is possible.

After doing the same for $$M=1456$$, we get that $$b\equiv 745,985 \pmod {1456}$$ if $$n \geq 12$$ and chosing $$M=1872$$ we get $$b \equiv 329,569 \pmod {1872}$$ if $$n \geq 12$$.

Combining these relations we get that $$b \equiv 41753,54857,107033,120137 \pmod {131040}$$ must hold (note that all $$n<12$$ have been verified not to result in a perfect power).

Now we shift our attention to the exponent, $$e$$. @munichmath correctly commented the ending digits of $$S(n)$$ for $$n>100$$, for this example I will only be using the last $$9$$ digits, which are $$069851817$$ and which hold if $$n \geq 24$$ (note that again all $$n < 24$$ have been verified). Thus, we must have $$b^e \equiv 69851817 \pmod {10^{9}}$$.

Taking $$b=41753$$ gives the first such value $$e=17150159$$, however $$\log_{10} b^e = e \cdot \log_{10}b > 79\cdot 10^6 > 15\cdot 10^6 > 2 \log_{10} (1248829!) > \log_{10} S(1248828)\,.$$

Note that to run a faster search you can first work modulo $$10^4$$, determine the congruences for the exponent to deliver the correct last $$4$$ digits $$1817$$ and then use those congruences to search up to a higher limit modulo $$10^9$$. Since all $$b \geq 41743$$ the search limit $$e$$ up to $$4\cdot10^6$$ suffices.

This is where I got stuck, there are too much possible values for $$b$$ that I needed to search.

• Also, to speed up my search of the triples, I was only interested in triples $(x, y, z)$ with $x$ prime, $z$ prime, and $z\equiv 1 \pmod x$. Iterating through those values I calculated $y\equiv S(x-1) \pmod z$ and checked if $y$ ever was an $x$th power modulo $z$ using a brute-force search. Jul 18, 2023 at 6:13
• *Mistake: I calculated $y=S(z-1) \bmod z$. Jul 18, 2023 at 6:24
• "I verified by brute force that $n>10^5$." - How did you do that? My program took several hours to get to $10^4$, with the time being approximately quadratic (so $10^5$ would take hundreds of hours). I mean, it can calculate $S(n)$ for all $n\leq10^4$ in seconds, but it takes much longer to check that they're not perfect powers. Jul 18, 2023 at 16:07
• @mr_e_man, I used Python with the gmpy2.is_power() function. The package gmpy2 is a Python variant of the GMP library. The search limit of $10^5$ took only a few hours on a single core. Jul 18, 2023 at 18:26
• About your previous comment - If $z$ is prime and $z-1=qx$, then $y$ is an $x$th power $\bmod z$ if and only if $y^q\equiv0$ or $1\bmod z$. This test is much faster than calculating $z$ many $x$th powers and comparing them to $y$. Jul 18, 2023 at 18:44