Home » Python Programs » LCM of Two Numbers in Python Using If Else

# LCM of Two Numbers in Python Using If Else

Simple program to lcm of two numbers in python using if else . The lcm numbers will be printed using the Python programming language. The simplest option for beginners is to use the Python language to solve multiple problems. The “smallest non-zero common number” that is a multiple of both numbers is the “least common multiple of two numbers”.

## def() Function in Python

The procedure for defining a function in Python is as follows. The keyword def is used to define a function. The name of the function is followed by the parameter(s) in (). The colon denotes the beginning of the function body, which is denoted by an indentation. The return statement determines the value to be returned inside the function body.

The start of the function header is indicated by the keyword def. A name for the function that can be used to distinguish it from others. The same criteria apply to naming functions as they do to naming identifiers in Python. We pass values to a function using parameters. Using def() function we have executed this lcm of two numbers in python using if else

## LCM Definition in Python

The smallest positive integer that is a multiple of both is the least common multiple (LCM) of two integers. The largest positive integer that divides two integers is called the greatest common divisor (GCD). The LCM and the GCD are combined to form the product of the two numbers.

## LCM of Two Numbers in Python Using If Else

``````a = int(input('Enter First Number '))
b = int(input('Enter Second Number'))
if (a > b):
biggest = a
else:
biggest = b
while(True):
if(biggest % a == 0 and biggest % b == 0):
print('The LCM of',a,'and',b,'is',biggest)
break
biggest += 1``````

Output

Result is 60