OFFSET
0,4
COMMENTS
A companion to A300728 where "smallest" is replaced with "largest".
FORMULA
Conjectured formulas according to n mod 4 in first column.
0, (n/4 - 1)(3n/4 + 1),
1 or 3, 4((n + 3)/4 - 1)(3(n + 3)/4 - 2),
2, 2((n + 2)/4 - 1)(3(n + 2)/4 - 1).
EXAMPLE
With n = 7, the solutions to k^2 + k*n + n^2 = j^2 are k = 8 and k = 33, therefore A300728(7) = 8 and a(7) = 33.
MATHEMATICA
s[n_] := Solve[j > 0 && k > 0 && k^2 + k*n + n^2 == j^2, {j, k}, Integers];
a[n_] := If[n == 0, 0, With[{sn = s[n]}, Which[sn == {}, 0, IntegerQ[k /. sn[[1]]], Max[k /. sn], True, 0]]];
Table[a[n], {n, 0, 100}]
PROG
(Python)
from sympy.abc import x, y
from sympy.solvers.diophantine.diophantine import diop_quadratic
def A367191(n): return max(diop_quadratic(x*(x+n)+n**2-y**2))[0] if n else 0 # Chai Wah Wu, Nov 11 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Jean-François Alcover, Nov 09 2023
STATUS
approved