Advertisement
immanual1

Untitled

Jan 13th, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. from math import gcd
  2.  
  3. def lcm(x, y):
  4. return (x * y) // gcd(x, y)
  5.  
  6. num1 = int(input("Enter the first number: "))
  7. num2 = int(input("Enter the second number: "))
  8.  
  9.  
  10. gcd_result = gcd(num1, num2)
  11. lcm_result = lcm(num1, num2)
  12.  
  13. # Print the results
  14. print("GCD of", num1, "and", num2, "is", gcd_result)
  15. print("LCM of", num1, "and", num2, "is", lcm_result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement