Logo

Programming-Idioms

History of Idiom 75 > diff from v21 to v22

Edit summary for version 22 by 1.7.4:
New JS implementation by user [1.7.4]

Version 21

2018-12-28, 09:41:08

Version 22

2019-01-25, 11:49:42

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.

Code
const gcd = (a, b) => b === 0 ? a : gcd (b, a % b)
let x = (a * b) / gcd(a, b)