OFFSET
0,3
COMMENTS
In other words, a(n)^2 is the largest sum of two square numbers <= n^2.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
Rémy Sigrist, PARI program
FORMULA
a(n) = A393159(n, n).
EXAMPLE
a(4) = 5 corresponds to the distance between, among others, the lattice points (0, 0) and (3, 4).
PROG
(PARI) \\ See Links section.
(Python)
from math import isqrt
def A393160(n):
c, s = 0, {x**2 for x in range(isqrt(n**2<<1)+1)}
for x in range(n+1):
z = x**2+(m:=isqrt(max(0, c-x**2)))**2
for y in range(m, x+1):
if z>c and z in s:
c = z
z += (y<<1)+1
return isqrt(c) # Chai Wah Wu, Feb 08 2026
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, Feb 03 2026
STATUS
approved
