RosettaCodeData/Task/Heronian-triangles/00-TASK.txt

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 &nbsp; <big> ''a'',</big> &nbsp; <big>''b'',</big> &nbsp; and &nbsp; <big>''c''</big> &nbsp; is given by:
:::: <big><math>A = \sqrt{s(s-a)(s-b)(s-c)},</math></big>
where &nbsp; <big>''s''</big> &nbsp; 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 &nbsp; '''3, 4, 5''' &nbsp; whose area is &nbsp; '''6''' &nbsp; (and whose perimeter is &nbsp; '''12''').
<br>
Note that any triangle whose sides are all an integer multiple of &nbsp; '''3, 4, 5'''; &nbsp; such as &nbsp; '''6, 8, 10,''' &nbsp; 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 &nbsp; '''1''' &nbsp; (unity).
This will exclude, for example, triangle &nbsp; '''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>