Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pythagorean triplets
- '''testcase1:
- input:
- 10
- output:
- 3 4 5
- 6 8 10
- testcase2:
- input:
- 15
- output:
- 3 4 5
- 6 8 10
- 5 12 13
- 9 12 15'''
- ......................................
- import math
- def py_triplets(n):
- for b in range(n):
- for a in range(1, b):
- c=math.sqrt(a*a + b*b)
- if c%1==0:
- print(a, b,int(c))
- x=int(input())
- py_triplets(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement