Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #pythagorean triplets
  2. '''testcase1:
  3. input:
  4. 10
  5. output:
  6. 3 4 5
  7. 6 8 10
  8. testcase2:
  9. input:
  10. 15
  11. output:
  12. 3 4 5
  13. 6 8 10
  14. 5 12 13
  15. 9 12 15'''
  16. ......................................
  17. import math
  18. def py_triplets(n):
  19. for b in range(n):
  20. for a in range(1, b):
  21. c=math.sqrt(a*a + b*b)
  22. if c%1==0:
  23. print(a, b,int(c))
  24. x=int(input())
  25. py_triplets(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement