How to resolve the algorithm Heronian triangles step by step in the Phix programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Heronian triangles step by step in the Phix programming language

Table of Contents

Problem Statement

Hero's formula for the area of a triangle given the length of its three sides   a,   b,   and   c   is given by: where   s   is half the perimeter of the triangle; that is,

Heronian triangles are triangles whose sides and area are all integers.

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.

Show all output here. Note: when generating triangles it may help to restrict

a <= b <= c

{\displaystyle a<=b<=c}

Let's start with the solution: