Random Right-Triangle Exercise Generator
Generate valid right triangles with one hidden measurement and computed side, area, and perimeter answers.
Description
Generate right-triangle questions with one hidden side and computed area, hypotenuse, and perimeter.
A right triangle has perpendicular legs and a hypotenuse opposite its right angle. The Pythagorean relationship connects the three lengths, letting a missing side be recovered from the other two.1
This generator samples two positive integer legs, calculates triangle measurements, and removes one side from the given fields. Each item in result.exercises contains given, hidden, and answer. The answer object contains area, hypotenuse, and perimeter; it does not directly include either leg.
When to use Random Right-Triangle Exercise Generator
Use it for missing-side right-triangle worksheets or fixtures that include computed measurements for answer checking.
How to use Random Right-Triangle Exercise Generator and understand its results
- Enter integer exerciseCount from 1 through 64 and integer maximumLeg from 1 through 1,000,000.
- Run and read each given object together with hidden, which names sideA, sideB, or hypotenuse as the question’s missing side.
- Keep answer separate from the learner-facing question. Read its hypotenuse directly when that side is hidden; recover a hidden leg from the given lengths or from 2 × answer.area divided by the given leg.
a,b = 1 + floor(randomDraw × maximumLeg); h = sqrt(a² + b²) Two draws sample the legs independently in inclusive [1, maximumLeg].
area = ab/2; perimeter = a + b + h A third draw selects one of sideA, sideB, and hypotenuse with equal index weight. The right-triangle calculator supplies the measurements.
The implementation copies the two nonhidden side values into given and retains the measurement object in answer. All lengths use the same caller-chosen unit; area uses its square.
{
"input": {
"exerciseCount": 3,
"maximumLeg": 20
},
"randomDraw": 0.25,
"output": {
"result": {
"exercises": [
{
"given": {
"sideB": 6,
"hypotenuse": 8.485281374238571
},
"hidden": "sideA",
"answer": {
"area": 18,
"hypotenuse": 8.485281374238571,
"perimeter": 20.48528137423857
}
},
{
"given": {
"sideB": 6,
"hypotenuse": 8.485281374238571
},
"hidden": "sideA",
"answer": {
"area": 18,
"hypotenuse": 8.485281374238571,
"perimeter": 20.48528137423857
}
},
{
"given": {
"sideB": 6,
"hypotenuse": 8.485281374238571
},
"hidden": "sideA",
"answer": {
"area": 18,
"hypotenuse": 8.485281374238571,
"perimeter": 20.48528137423857
}
}
]
}
}
} Maximum leg one always gives legs one and one, while the third draw still selects which side to hide. Integer legs do not guarantee an integer hypotenuse. Zero bounds, counts above 64, and invalid draws fail.
Limitations and assumptions
The default source is Math.random; no seed input or cryptographic entropy guarantee is provided. Repeated runs may select the same result, and the distribution depends on the random source.
The generator does not select Pythagorean triples, guarantee distinct questions, render diagrams, or score answers. Answer fields are included in every result and must be concealed separately in a learner interface.
Neither sideA nor sideB is present in answer, even when hidden names a leg. Floating-point hypotenuse and perimeter values may need display rounding.
Alternative or Complementary methods
Use the deterministic calculator for a chosen right triangle. A general triangle generator creates a different family of side-and-angle fixtures.
References
-
Prealgebra 2e: Use the Pythagorean Theorem — OpenStax, Rice University
Similar or alternative tools
- Right Triangle
Calculate measurements from explicit perpendicular legs.
- Random Triangle Set Generator
Generate general triangles with a different construction rule.