Skip to Main Content
Blog

Calculate LCM of numbers in Python

Calculate LCM of numbers in Python

Enter a: 4
Enter b: 6
LCM: 12
from math import lcm


def main():
	"""
	Finds the least common multiple of two numbers.
	"""

	a = int(input("Enter a: "))
	b = int(input("Enter b: "))

	m = lcm(a, b)
	print(m)


if __name__ == "__main__":
	main()