Aim:
Write a function to compute gcd, lcm of two numbers. Each function shouldn’t exceed one line.
Program:
import fractions n1 = int(input("Enter n1 value:")) n2 = int(input("Enter n2 value:")) gcd = fractions.gcd(n1, n2) print("GCD value is:",gcd) def lcm(n, m): return n * m / gcd print("LCM value is:",int(lcm(n1,n2)))
Execution:
Enter n1 value: 5 Enter n2 value: 9 GCD value is: 1 LCM value is: 45