Advertisements
Advertisements
Question
Write a Python code to find the L.C.M. of two numbers.
Advertisements
Solution
Program:
# Python Program to find the L.C.M. of two input number
defcompute_lcm(x, y):
# choose the greater number
if x > y:
greater = x
else:
greater = y
while (True):
if((greater % x == 0) and (greater % y == 0)):
1cm = greater
break
greater += 1
return 1cm
num1=int(input(//Enter first number=”))
num2=int(input(“Enter second number=”))
print
(“The L.C.M. is”, compute_lcm(num1, num2))
Output:
Enter first number=8
Enter second number=4
The L.C.M. is 8.
APPEARS IN
RELATED QUESTIONS
A named block of code that is designed to do one specific job is called ______
A Function which calls itself is called as ______
Which function is called anonymous un-named function?
Read the following statement and choose the correct statement.
In Python, you don’t have to mention the specific data types while defining the function.
What is a function?
Differentiate ceil() and floor() function?
What are the points to be noted while defining a function?
Explain the following built-in function.
id()
Explain the following built-in function.
round()
Explain the following built-in function.
pow()
