A375202 a(n) is the least integer x >= 0 such that n = x^2 + y^2 + z^2 for some integers y, z, or -1 if there is no such x.
0, 0, 0, 1, 0, 0, 1, -1, 0, 0, 0, 1, 2, 0, 1, -1, 0, 0, 0, 1, 0, 1, 2, -1, 2, 0, 0, 1, -1, 0, 1, -1, 0, 1, 0, 1, 0, 0, 1, -1, 0, 0, 1, 3, 2, 0, 1, -1, 4, 0, 0, 1, 0, 0, 1, -1, 2, 2, 0, 1, -1, 0, 1, -1, 0, 0, 1, 3, 0, 1, 3, -1, 0, 0, 0, 1, 2, 2, 2, -1, 0, 0, 0, 1, 2, 0, 1, -1, 4, 0, 0, 1, -1, 2, 2
Offset: 0
Keywords
Examples
a(12) = 2 because 12 = 2^2 + 2^2 + 2^2 but there are no integer solutions to 12 = 0^2 + y^2 + z^2 or 12 = 1^2 + y^2 + z^2.
Links
- Robert Israel, Table of n, a(n) for n = 0..10000
- Mathematics StackExchange, Large smallest square in a sum of three squares?
Programs
-
Maple
f:= proc(n) local q,x,y,z; if n/4^padic:-ordp(n,4) mod 8 = 7 then return -1 fi; for x from 0 while 3*x^2 <= n do if [isolve(y^2 + z^2 = n - x^2)] <> [] then return x fi od; end proc; map(f, [$0..100]);
-
Python
from math import isqrt from sympy import factorint def A375202(n): v = (~n & n-1).bit_length() if v&1^1 and n>>v&7==7: return -1 for x in range(isqrt(n//3)+1): if not any(e&1 and p&3==3 for p, e in factorint(n-x**2).items()): return x # Chai Wah Wu, Oct 16 2024
Formula
a(n) = A064874(n) if a(n) >= 0.
If a(n) = -1 then a(4*n) = -1, otherwise a(4*n) = 2*a(n).
Comments