|
% cat gcd.py
def gcd(a, b):
if a < b:
a, b = b, a
if a % b == 0:
return b
return gcd(b, a % b)
if __name__ == '__main__':
x, y = [int(n) for n in input("Two numbers for GCD:").split()[:2]]
z = gcd(x, y)
print("GCD(%d, %d) = %d" % (x, y, z))
% cat lcd.py
import gcd as gcd
def lcd(a, b):
c = gcd.gcd(a, b)
d, e = a // c, b // c
return d * e * c
if __name__ == '__main__':
x, y = [int(n) for n in input("Two numbers for LCD:").split()[:2]]
z = lcd(x, y)
print("LCD(%d, %d) = %d" % (x, y, z)) |
|