Bill Allombert on Mon, 04 Dec 2023 11:35:24 +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).
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: number of ways of writing a nonnegative integer n as a sum of 3 squares (zero being allowed).
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Mon, 4 Dec 2023 10:17:20 +0100
- Delivery-date: Mon, 04 Dec 2023 11:35:24 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1701681441; bh=EsDUxQqvSZFBrd23oZGbXuZz9/d2qz6CQNGTjGbjELU=; h=Date:From:To:Subject:References:In-Reply-To:From; b=WPa3OnOO1TeDULDVEEtOKwmW+kfgtxg2COIN35sLyIq6wOO8AsZfbJVm+q+DZ9+SS Yp9k+sCY6ePxgrINnGmrBaYQ1XdRxXn6Gka/xBwfnUZzV2mBiP4O3K5jHdEaXJ7ZUh UJ6p/iDLrr2EcVb+r21CkA9AM7+Gtmjn1onGqWWu7JAp8eZgAZqXemDyFHya66x9hg RmbNJ49oII/JScMiEZ8d76JPx3jYagxltMnovEbLVueOPScNPPB6cpFsIo78tRlL87 fXoUmfSkNBcrM1czhMBPeaPOUQmBhT8XiSxZ7xBVoMICrllAssZC+27ZBmsxVBTCnb mj+PXkA2m2/8Z3V6qQEskt1IS76DM5htjJMgtq5l9H8aex6YQYNZ+5zZjrQHSpAPaH ZjmdTMOxJei4NQ36H80LnattvyHnPV3hK1Kkpqn4yAOZrjeGtNP14qQ89vGySpa6HG 79Yn65iXXsrnp9WDOzIEdEbc0BZ0SiJz9WXFV9nu5IMmL/zPest9wUiX0zM+JNKCtD 7QYn7WbasXR0/lTst1X/brlxreiq8zQnSpcm6rnmqzAk8awhK+fc+0O0jT0bvl5mFL j6zuP+B1kEpFhv8QHvKzA0xPAgfzamtfoK20m+/yLu0zR1m1OG9WXSMrFZ3GBBRhJL Shh4/zDVeKjdTfj5ICpellXQ=
- In-reply-to: <d485efad-9b3c-42da-b646-4a3fdfbc853d@wavecable.com>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <d485efad-9b3c-42da-b646-4a3fdfbc853d@wavecable.com>
On Sun, Dec 03, 2023 at 11:03:08PM -0800, Thomas D. Dean wrote:
> Sorry if this too far off topic.
>
> I have been looking at OEIS, A005875, and can not understand their counting.
> I can see the Pari code and understand how it works.
>
> OEIS calls this "number of ways of writing a nonnegative integer n as a sum
> of 3 squares (zero being allowed)." or "Number of ordered triples (i, j, k)
> of integers such that n = i^2 + j^2 + k^2." So, i,j,and, k should be
> considered distinct even if they are numerically equal?
I can only assume that by 'ordered triples' they just means vectors of length 3,
and not that the values are ordered.
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])))));
? fun(1)
1:[-1,0,0]
2:[0,-1,0]
3:[0,0,-1]
4:[0,0,1]
5:[0,1,0]
6:[1,0,0]
? fun(2)
1:[-1,-1,0]
2:[-1,0,-1]
3:[-1,0,1]
4:[-1,1,0]
5:[0,-1,-1]
6:[0,-1,1]
7:[0,1,-1]
8:[0,1,1]
9:[1,-1,0]
10:[1,0,-1]
11:[1,0,1]
12:[1,1,0]
etc.
Cheers,
Bill.