6

1

I want to check the following theorem by using *Mathematica*:

$\textbf{Theorem} $. $\text{The estimate}$

$\# \{n \le x:n! \text{ is a sum of three squares}\}=7x/8+O(x^{2/3})$

$\text{holds.}$

(The positive integers $n$ such that $n!$ is a sum of three squares have a density which is equal to $7/8$.)

I tried:

```
Solve[{n! == x^2 + y^2 + z^2}, {x, y, z, n}, Integers]
```

but there is an error message.

I want to do something like this (find the all perfect number from $1$ to $1000$)

```
Select[Range[1000], DivisorSigma[1, #] == 2 # &]
```

How do I find the number of $n$ such that $n!$ is a sum of three squares?

1Make your search space bounded:

`Solve[{n! == x^2 + y^2 + z^2, x <= y <= z, Sequence @@ (0 < # < 70 & /@ {x, y, z})}, {x, y, z, n}, Integers] (* {{x -> 1, y -> 1, z -> 2, n -> 3}, {x -> 2, y -> 2, z -> 4, n -> 4}, {x -> 2, y -> 4, z -> 10, n -> 5}, {x -> 4, y -> 20, z -> 68, n -> 7}, {x -> 8, y -> 16, z -> 20, n -> 6}, {x -> 12, y -> 36, z -> 60, n -> 7}, {x -> 20, y -> 44, z -> 52, n -> 7}} *)`

- this is not necessarily fast, but it works. – kirma – 2016-04-24T11:34:42.1301@vito This was a neat problem. Where did you see this theorem btw? – Chip Hurst – 2016-04-26T02:40:40.690

@ChipHurst "The Legacy of Alladi Ramakrishnan in the Mathematical sciences". page 243 – vito – 2016-04-26T07:34:34.870