afzalsiddique

question1

Oct 13th, 2021
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. def get_gcd(a, b):
  2. if b>a: return get_gcd(b, a)
  3. if b==0: return a
  4. return get_gcd(a - b, b)
  5.  
  6. def print_gcd_and_lcm():
  7. floating = False
  8. x = input('Enter first integer: ')
  9. if '.' in x: floating=True
  10. y = input('Enter second integer: ')
  11. if '.' in y: floating=True
  12. x = int(x)
  13. y = int(y)
  14. if floating:
  15. print('floating value is not acceptable')
  16. return
  17. gcd = get_gcd(x,y)
  18. lcm = x*y//gcd
  19. print('gcd is {}'.format(gcd))
  20. print('lcm is {}'.format(lcm))
  21.  
  22. print_gcd_and_lcm()
  23.  
Advertisement
Add Comment
Please, Sign In to add comment