**GCD and LCM in Python**

The logic to find the GCD and LCM is quite simple. First write a function to get GCD and then write function to get LCM of the number. GCD can get calculated by the logic to find reminder after dividing one number by another, next time dividing the divisor by reminder left out. Continue the process till divisor is greater then zero. Now to get LCM we need to apply logic to divide the multiplication of numbers by the GCD value of numbers. Like if a and b are two numbers then the LCM will (aXb)/gcd(a,b). Lets look into the program.

**Output will be like this – **

**Enter first number – 4Enter second number – 12GCD of 4 and 12 is = 4LCM of 4 and 12 is = 12.0**

## ppadmin says:

Best way to calculate GCD and LCM in python.

## http://canadianorderpharmacy.com/ says:

That is a very good tip especially to those new to the blogosphere. Brief but very accurate info… Thanks for sharing this one. A must read post!