a=5,b=12,c=13 which is again the Pythagorean triplet.take some more value for m and n and generate nor for such triplet
Answers
Answered by
0
Step-by-step explanation:
Generate Pythagorean Triplets
A Pythagorean triplet is a set of three positive integers a, b and c such that a2 + b2 = c2. Given a limit, generate all Pythagorean Triples with values smaller than given limit.
Input : limit = 20
Output : 3 4 5
8 6 10
5 12 13
15 8 17
12 16 20
A Simple Solution is to generate these triplets smaller than given limit using three nested loop. For every triplet, check if Pythagorean condition is true, if true, then print the triplet. Time complexity of this solution is O(limit3) where ‘limit’ is given limit.
Similar questions