Python Program to Find LCM of Two Numbers



The LCM of two numbers is the smallest positive integer that is perfectly divisible by the two given numbers.



  1. # Python Program to find the L.C.M. of two input number
  2. a=int(input("Enter first number: "))
  3. b=int(input("Enter seconf number: "))
  4. def lcm(x, y):
  5. if x > y:
  6. greater = x
  7. else:
  8. greater = y
  9. while(True):
  10. if((greater % x == 0) and (greater % y == 0)):
  11. lcm = greater
  12. break
  13. greater += 1
  14. return lcm
  15. print("The L.C.M. is", lcm(a, b))

Output
Output!
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


Join Our Facebook Group


Share this example


Download Android App





codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube