Perl Weekly Challenge 125: Pythagorean Triples
These are some answers to the Week 125 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Task 1: Pythagorean Triples
You are given a positive integer $N.
Write a script to print all Pythagorean Triples containing $N as a member. Print -1 if it can’t be a member of any.
Triples with the same set of elements are considered the same, i.e. if your script has already printed (3, 4, 5), (4, 3, 5) should not be printed.
The famous Pythagorean theorem states that in a right angle triangle, the length of the two shorter sides and the length of the longest side are related by a²+b² = c².
A Pythagorean triple refers to the triple of three integers whose lengths can compose a right-angled triangle.
Example:






