Python Program to Find All Pythagorean Triplets in the Range
limit=int(input("Enter upper limit:"))
c=0
m=2
while(c<limit):
for n in range(1,m+1):
a=m*m-n*n
b=2*m*n
c=m*m+n*n
if(c>limit):
break
if(a==0 or b==0 or c==0):
break
print(a,b,c)
m=m+1
Output
Enter upper limit:20
3 4 5
8 6 10
5 12 13
15 8 17
12 16 20
