Logo

Programming-Idioms

History of Idiom 75 > diff from v5 to v6

Edit summary for version 6 by :

Version 5

2015-08-21, 13:14:56

Version 6

2015-08-22, 10:25:14

Idiom #75 Compute LCM

Compute the least common multiple x of big integers a and b. Use an integer type able to handle huge numbers.

Idiom #75 Compute LCM

Compute the least common multiple x of big integers a and b. Use an integer type able to handle huge numbers.

Imports
from fractions import gcd
Code
x = (a*b)//gcd(a, b)
Origin
http://www.programiz.com/python-programming/examples/lcm