login
Integers whose square root is the longest side of a non-right triangle whose side lengths are also square roots of integers, and with integer area.
7

%I #55 Mar 11 2021 03:21:55

%S 5,8,9,10,13,15,16,17,18,20,24,25,26,27,29,30,32,34,35,36,37,39,40,41,

%T 45,48,49,50,51,52,53,54,55,56,58,60,61,63,64,65,68,70,72,73,74,75,78,

%U 80,81,82,85,87,88,89,90,91,95,96,97,98,99,100,101,102

%N Integers whose square root is the longest side of a non-right triangle whose side lengths are also square roots of integers, and with integer area.

%C Equivalent to finding all integer triples (a,b,c) such that sqrt(4*a*b-(a+b-c)^2) is an integer multiple of 4.

%C All Pythagorean triples satisfy this criterion; if (a,b,c) is a Pythagorean triple then a and b cannot be odd, so the triangle has integer area.

%C If m is in the list, so is 4m.

%H Samuel Bodansky, <a href="/A334818/b334818.txt">Table of n, a(n) for n = 1..100</a>

%e The triangle with side lengths sqrt(8), sqrt(9) and sqrt(29) has area 3 and is not a right triangle, so 29 is in the list.

%e The triangle with side lengths sqrt(53), sqrt(65) and sqrt(72) has area 27 and is not a right triangle, so 72 is in the list.

%t ok[c_] := Catch[ Do[ If[ a+b != c && 4 a b > (c-a-b)^2 && IntegerQ[ Sqrt[2 a (b+c) - a^2 - (b-c)^2]/4], Throw@ True], {a,c}, {b,a}]; False]; Select[ Range@ 96, ok] (* _Giovanni Resta_, May 13 2020 *)

%o (Python)

%o import numpy as np

%o import math

%o def is_square(n):

%o return math.isqrt(n) ** 2 == n

%o def is_valid_triangle(a, b, c):

%o return ((a + b) > c) and ((b + c) > a) and ((a + c) > b)

%o def aList(upto): # Number to check up to

%o my_list = []

%o for i in range(upto):

%o sqrti = np.sqrt(i)

%o for j in range(i + 1):

%o sqrtj = np.sqrt(j)

%o for k in range(i + 1):

%o sqrtk = np.sqrt(k)

%o if is_valid_triangle(sqrti, sqrtj, sqrtk):

%o test = 4 * i * j - (i + j - k) ** 2

%o if is_square(test) and test % 16 == 0 and (i != j + k):

%o my_list.append(i)

%o return list(set(my_list))

%o print(aList(103))

%K nonn

%O 1,1

%A _Samuel Bodansky_, May 12 2020