A triangle and rectangle have the same area and perimeter. All sides are integers.
Find such a pair with the smallest area? And the next smallest?
Can you find such a pair with a right triangle?
The program uses Heron's formula for the area of the triangle:
DEFDBL A-Z
CLS
FOR peri = 4 TO 9999 STEP 2
FOR w = 1 TO peri / 4
l = peri / 2 - w
area = l * w
FOR s1 = 1 TO peri / 3
FOR s2 = s1 TO (peri - s1) / 2
s3 = peri - s1 - s2
IF s1 + s2 > s3 THEN
s = peri / 2
tarea = SQR(s * (s - s1) * (s - s2) * (s - s3))
IF tarea = area THEN
PRINT l; w, s1; s2; s3; TAB(30); area;
IF s1 * s1 + s2 * s2 = s3 * s3 THEN PRINT " right": ELSE PRINT
END IF
END IF
NEXT s2
NEXT s1
NEXT w
NEXT peri
finds as the first few, in order of increasing perimeter:
rect.: triangle: area
l w sides
6 2 5 5 6 12
12 4 10 10 12 48
18 6 15 15 18 108
21 6 13 20 21 126
24 8 20 20 24 192
30 10 25 25 30 300
36 12 30 30 36 432
42 12 26 40 42 504
42 14 35 35 42 588
52 12 25 51 52 624
48 16 40 40 48 768
54 18 45 45 54 972
60 20 50 50 60 1200
63 18 39 60 63 1134
60 21 53 53 56 1260
66 22 55 55 66 1452
72 24 60 60 72 1728
78 26 65 65 78 2028
84 24 52 80 84 2016
84 28 70 70 84 2352
90 30 75 75 90 2700
105 20 41 104 105 2100
95 30 68 87 95 2850
104 24 50 102 104 2496
96 32 80 80 96 3072
105 30 65 100 105 3150
102 34 85 85 102 3468
108 36 90 90 108 3888
114 38 95 95 114 4332
120 40 100 100 120 4800
150 12 37 130 157 1800
126 36 78 120 126 4536
126 36 81 113 130 4536
120 42 106 106 112 5040
126 42 105 105 126 5292
132 44 110 110 132 5808
138 46 115 115 138 6348
147 42 91 140 147 6174
156 36 75 153 156 5616
144 48 120 120 144 6912
None were indicated to be right triangles.
The smallest area was 12 and the next smallest 48.
|
Posted by Charlie
on 2013-11-01 11:27:22 |