I stumbled across the following problem in high school:$$ x^2 + y^2 = n! $$ I tested it within my laptop capabilities, watched a 3b1b video Pi in prime regularities, where he explains how to find the number of integer solutions based on prime factors. There doesn't seem to be any above $30!$. Maybe I'm wrong and there are infinitely many exceptions like $2$ and $6$, maybe the proof is too difficult for me to grasp or... I hope I'm just too blind to see the obvious.

  • $\begingroup$ Hi and welcome to MO. What is your question? $\endgroup$
    – Amir Sagiv
    Mar 30, 2019 at 12:31
  • 1
    $\begingroup$ Hi. The question is: are there any integers above 6 for which this equation has integer pairs (x,y) as solutions. $\endgroup$
    – Betydlig
    Mar 30, 2019 at 12:35
  • 24
    $\begingroup$ At least for sufficiently large $n$, there will be a prime $p \equiv 3 \bmod 4$ such that $p \le n < 2p$. Then $p$ divides $n!$ exactly once, hence $n!$ cannot be a sum of two squares. $\endgroup$ Mar 30, 2019 at 12:45

1 Answer 1


For $n\geq 7$, Erdős proved in 1932 that there is a prime $n/2<p\leq n$ of the form $p=4k+3$. From this he deduces (in the same paper) that $1!$, $2!$, $6!$ are the only factorials which can be written as a sum of two squares.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.