%I #23 Nov 12 2023 00:06:49
%S 0,0,0,5,0,16,10,33,7,56,32,85,20,120,66,161,39,208,112,261,64,320,
%T 170,385,95,456,240,533,132,616,322,705,175,800,416,901,224,1008,522,
%U 1121,279,1240,640,1365,340,1496,770,1633,407,1776,912,1925,480,2080,1066,2241,559,2408,1232,2581,644,2760,1410,2945
%N a(n) is the largest positive number k such that k^2 + k*n + n^2 is a perfect square, or 0 if no such k exists.
%C A companion to A300728 where "smallest" is replaced with "largest".
%F Conjectured formulas according to n mod 4 in first column.
%F 0, (n/4 - 1)(3n/4 + 1),
%F 1 or 3, 4((n + 3)/4 - 1)(3(n + 3)/4 - 2),
%F 2, 2((n + 2)/4 - 1)(3(n + 2)/4 - 1).
%e 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.
%t s[n_] := Solve[j > 0 && k > 0 && k^2 + k*n + n^2 == j^2, {j, k},Integers];
%t a[n_] := If[n == 0, 0, With[{sn = s[n]}, Which[sn == {}, 0, IntegerQ[k /. sn[[1]]], Max[k /. sn], True, 0]]];
%t Table[a[n], {n, 0, 100}]
%o (Python)
%o from sympy.abc import x,y
%o from sympy.solvers.diophantine.diophantine import diop_quadratic
%o 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
%Y Cf. A003136, A300728.
%K nonn
%O 0,4
%A _Jean-François Alcover_, Nov 09 2023
|