Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_gcd(a, b):
- if b>a: return get_gcd(b, a)
- if b==0: return a
- return get_gcd(a - b, b)
- def print_gcd_and_lcm():
- floating = False
- x = input('Enter first integer: ')
- if '.' in x: floating=True
- y = input('Enter second integer: ')
- if '.' in y: floating=True
- x = int(x)
- y = int(y)
- if floating:
- print('floating value is not acceptable')
- return
- gcd = get_gcd(x,y)
- lcm = x*y//gcd
- print('gcd is {}'.format(gcd))
- print('lcm is {}'.format(lcm))
- print_gcd_and_lcm()
Advertisement
Add Comment
Please, Sign In to add comment