12
24
24
# Python Program to find the LCM of Two Numbers
num1 = int(input()) # Input first number
num2 = int(input()) # Input second number
if num1 > num2:
max_num = num1
else:
max_num = num2
while True:
if max_num % num1 == 0 and max_num % num2 == 0:
print(max_num)
break
max_num += 1num1
and num2
.12
24
24
# Python Program to find LCM of Two Numbers using Functions
def find_lcm(a, b):
if a > b:
maximum = a
else:
maximum = b
while True:
if maximum % a == 0 and maximum % b == 0:
lcm = maximum
break
maximum += 1
return lcm
# Taking inputs from the user
num1 = int(input())
num2 = int(input())
lcm = find_lcm(num1, num2) # Function call
print(lcm)12
26
156
# Python Program to find the LCM of Two Numbers using GCD
num1 = int(input()) # Input first number
num2 = int(input()) # Input second number
# Find GCD using Euclidean algorithm
a = num1
b = num2
while b != 0:
temp = b
b = a % b
a = temp
gcd = a
lcm = (num1 * num2) // gcd # LCM using GCD
print(lcm)3
8
24
# Python Program to find the LCM of Two Numbers using Recursion
def find_gcd(a, b):
if b == 0:
return a
else:
return find_gcd(b, a % b)
num1 = int(input()) # Input first number
num2 = int(input()) # Input second number
gcd = find_gcd(num1, num2) # Function call to find GCD
lcm = (num1 * num2) // gcd # LCM using the formula
print(lcm)28
56
56