How many different triangles with integer side lengths are there such that the sum of the lengths of any 2 sides is at least 5 units more than the length of the third side, and that the area is numerically twice the perimeter?
I found 8
x y z area perim
9 40 41 180 90
9 75 78 324 162
10 24 26 120 60
10 35 39 168 84
11 25 30 132 66
12 16 20 96 48
13 14 15 84 42
15 15 24 108 54
I haven't proved that there are none for triangles with a side larger than 1,000.
Code follows:
count = 0
threshold = .0001
print(' x ' , 'y ' , 'z ' , 'diff,' , 'area,' , 'perimeter')
for x in (range(1,1000)):
for y in (range(x,1000)):
for z in (range(y,1000)):
if x+y-z < 5:
continue
s = (x+y+z)/2
area = ((s*(s-x)*(s-y)*(s-z))**.5)
if abs(area - 2*(x+y+z)) < threshold:
print(x , y, z, int(area), x+y+z)
count += 1
print('number of solutions is: ', count)
Edited on November 21, 2019, 11:26 am
|
Posted by Larry
on 2019-11-21 11:14:56 |