Skip to content

Commit cef7442

Browse files
Merge pull request #1454 from Rituraj-M50/patch-3
Create pythagoreanTriplets.py
2 parents b404e3f + 65d2e19 commit cef7442

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pythagoreanTriplets.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
limit=int(input("Enter upper limit:"))
2+
c=0
3+
m=2
4+
while(c<limit):
5+
for n in range(1,m+1):
6+
a=m*m-n*n
7+
b=2*m*n
8+
c=m*m+n*n
9+
if(c>limit):
10+
break
11+
if(a==0 or b==0 or c==0):
12+
break
13+
print(a,b,c)
14+
m=m+1

0 commit comments

Comments
 (0)