OFFSET
1,1
COMMENTS
We can prove that for every positive integer n there exists a triple (x,y,z) of positive integers such that x^2 + n*x*y + y^2 = z^2. One of the solutions is (s^2 - t^2, n*t^2 + 2*s*t, s^2 + n*s*t + t^2).
LINKS
Mathematics StackExchange, Finding all pairs (a,b) of positive integers such that a^2+nab+b^2 is a perfect square.
EXAMPLE
a(6)=7 because there exists a triple (2,3,7) satisfying 2^2 + 6*2*3 + 3^2 = 7^2, and no smaller solution exists.
MATHEMATICA
Table[First[
Sort@Flatten[
Table[Sqrt[x^2 + n*x*y + y^2], {x, 1, 50}, {y, x + 1, 50}]],
IntegerQ[#] &], {n, 1, 30}]
PROG
(Python)
def a(n):
for z in range(1, 100):
for y in range(z, 1, -1):
for x in range(1, y):
if x**2+n*x*y+y**2==z**2:
return(z)
print([a(n) for n in range(1, 30)])
CROSSREFS
KEYWORD
nonn
AUTHOR
Zhining Yang, Mar 11 2023
EXTENSIONS
More terms from Sean A. Irvine, Apr 10 2023
STATUS
approved