Re: N = a^2 + b^2 + c^2 question

Max Alekseyev <[email protected]> Mon, 17 Nov 2025 09:28:33 -0500
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <CAJkPp5NZUJ3FqKx8f+EF00DPF0pfD8a5z2CO9N+5=6=PpD6BgQ@mail.gmail.com>
There is an analytical formula for this count - see
https://en.wikipedia.org/wiki/Sum_of_squares_function#k_=_3

Regards,
Max


On Mon, Nov 17, 2025 at 4:59 AM Bill Allombert <
[email protected]> wrote:

> On Sun, Nov 16, 2025 at 05:32:52PM -0800, American Citizen wrote:
> > In trying to obtain a fast but exhaustive algorithm for finding 3 squares
> > which sum to a given number n, I found that using n = 416666, I obtained
> 339
> > unique representations of [a,b,c] such that a^2+b^2+c^2 = n.
> >
> > Can anyone verify that this count is correct for n?
>
> Yes this is correct. Using the most straightword way:
> ?
> my(c=0);forvec(v=[[0,1000],[0,1000],[0,1000]],if(norml2(v)==416666,c++;print(c,":",v)),1);print(c);
> %1 = 339
>
> Cheers,
> Bill.
>
>