LCM Check
Problem Description
Write a python function to calculate the LCM of numbers
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output
CODING ARENA
def lcm(x, y):
if x > y:
greater = x
else:
greater = y
while(True):
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1
return lcm
num1 = int(input())
num2 = int(input())
print("LCM is:",lcm(num1, num2))
Test Case 1
Input (stdin)5
3
Expected Output
LCM is: 15
Test Case 2
Input (stdin)15
20
Expected Output
LCM is: 60
No comments:
Post a Comment