SHARE
TWEET

Untitled

a guest Jul 17th, 2019 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top