Maths WorkshopMaths problems with full solutions
Exercise 643Number theory › Diophantine equationsM1Added 5 Nov 2026

When is 1! + 2! + … + n! a perfect square?

#squares modulo n#factorials#Diophantine

Statement

Find all positive integers nn such that 1!+2!+⋯+n!1!+2!+\dots+n! is a perfect square.

Hint

For large nn most of the terms are multiples of 55. Which residues can a square have modulo 55?

Show solutionHide solution

Solution

Small cases. n=1n=1: 1=121=1^2. n=2n=2: 33, not a square. n=3n=3: 1+2+6=9=321+2+6=9=3^2. n=4n=4: 3333, not a square.

Large nn. For k≥5k\ge5, 5∣k!5\mid k!. So for n≥4n\ge4,
1!+⋯+n!≡1+2+6+24=33≡3(mod5).1!+\dots+n!\equiv1+2+6+24=33\equiv3\pmod5.
But squares modulo 55 are only 0,1,40,1,4, so 33 is not a square modulo 55.

Answer. n=1n=1 and n=3n=3.

Lesson. To show that an equation has no solutions, find a modulus in which the sum stabilises and the target is not a square (here 55, where the factorials die out).