This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A369862 #16 Feb 04 2024 18:36:20 %S A369862 2,1,-2,0,2,-1,-1,1,0,-4,-1,0,2,0,-4,0,-1,1,0,-1,-1,-1,-2,0,0,-1,-1,0, %T A369862 0,-1,-1,1,0,0,-4,0,-1,0,0,0,-1,-1,-1,0,-1,-1,-1,-3,0,0,0,0,-4,0,3,-1, %U A369862 0,-4,0,0,-1,-1,-1,0,4,-1,0,-4,0,-3,-1,0,0,0,-1,-1,0,-4,0,1,0,-1,-2,0,-1,0,-1,0,0,0,-1,-1,3,0,-1,0,-1,1 %N A369862 a(n) is the smallest error in trying to solve n^2 = x^2 + y^2: given n >= 2, find positive integers x <= y < n such that |n^2 - x^2 - y^2| is minimal and let a(n) = n^2 - x^2 - y^2. In case of a tie, choose the value with the smallest y. %C A369862 We impose y < n to exclude the trivial solution x = 1, y = n, a(n) = -1. %C A369862 Then there is no admissible pair (x, y) for n = 1, whence a(1) is undefined. %F A369862 a(n) = 0 for Hypotenuse numbers, n in A009003. %e A369862 For n = 2, the largest possible x = y = 1 give the minimal n^2 - x^2 - y^2 = 4 - 2 * 1^2 = 2 = a(2). %e A369862 Similarly, for n = 3 and n = 4, the largest possible x = y = n - 1 give the minimal a(n) = n^2 - 2*(n-1)^2, a(3) = 9 - 2*4 = 1 and a(4) = 16 - 2*9 = -2. %e A369862 For n = 5 which is a hypotenuse number (<=> has a prime factor of the form 4k+1), we have a(5) = 5^2 - 3^2 - 4^2 = 0. %o A369862 (PARI) A369862(n, p=2) = { my(np=n^p, m=np); for(y=max(sqrtnint(np\2, p), 1), n-1, my(x = sqrtnint(np - y^p, p), dy = np-y^p, d = if(dy-x^p > (x+1)^p-dy && x < n-1, dy-(x+1)^p, dy-x^p)); abs(d) < abs(m) && !(m=d) && break); m} \\ Not optimized: one could immediately return 0 when a solution of x^2 + y^2 = n^2 is known to exist, and similarly with n^2 +- k for small k. %Y A369862 Cf. A135998 (equivalent for 3rd powers), A308834 (4th powers), A369855 (5th powers). %Y A369862 Cf. A009003. %K A369862 sign %O A369862 2,1 %A A369862 _M. F. Hasler_, Feb 03 2024