Thomas D. Dean on Tue, 05 Dec 2023 19:53:13 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: number of ways of writing a nonnegative integer n as a sum of 3 squares (zero being allowed).


On 12/4/23 01:17, Bill Allombert wrote:
...

Try this:
fun(n)=my(a=sqrtint(n),c=0);for(i=-a,a,for(j=-a,a,for(k=-a,a,if(i^2+j^2+k^2==n,print(c++,":",[i,j,k])))));

...

I distributed nonnegative thru n and i,j,and k.

Sorry for the noise. But, all was not wasted, I learned something.

Tom Dean