36 lines
1.7 KiB
Plaintext
36 lines
1.7 KiB
Plaintext
[[wp:Heron's formula|Hero's formula]] for the area of a triangle given the length of its three sides <big> ''a'',</big> <big>''b'',</big> and <big>''c''</big> is given by:
|
|
|
|
:::: <big><math>A = \sqrt{s(s-a)(s-b)(s-c)},</math></big>
|
|
|
|
where <big>''s''</big> is half the perimeter of the triangle; that is,
|
|
|
|
:::: <big><math>s=\frac{a+b+c}{2}.</math></big>
|
|
|
|
<br>
|
|
'''[http://www.had2know.com/academics/heronian-triangles-generator-calculator.html Heronian triangles]'''
|
|
are triangles whose sides ''and area'' are all integers.
|
|
: An example is the triangle with sides '''3, 4, 5''' whose area is '''6''' (and whose perimeter is '''12''').
|
|
|
|
<br>
|
|
Note that any triangle whose sides are all an integer multiple of '''3, 4, 5'''; such as '''6, 8, 10,''' will also be a Heronian triangle.
|
|
|
|
Define a '''Primitive Heronian triangle''' as a Heronian triangle where the greatest common divisor
|
|
of all three sides is '''1''' (unity).
|
|
|
|
This will exclude, for example, triangle '''6, 8, 10.'''
|
|
|
|
|
|
;Task:
|
|
# Create a named function/method/procedure/... that implements Hero's formula.
|
|
# Use the function to generate all the ''primitive'' Heronian triangles with sides <= 200.
|
|
# Show the count of how many triangles are found.
|
|
# Order the triangles by first increasing area, then by increasing perimeter, then by increasing maximum side lengths
|
|
# Show the first ten ordered triangles in a table of sides, perimeter, and area.
|
|
# Show a similar ordered table for those triangles with area = 210
|
|
|
|
<br>
|
|
Show all output here.
|
|
|
|
<small>'''Note''': when generating triangles it may help to restrict</small> <math>a <= b <= c</math>
|
|
|