Algorithms Flashcards
1
Q
Euclid’s Theorem for GCD
A
Greatest_common_divisor#Euclid’s_algorithm
const gcd = (a, b) => (b === 0) ? a : gcd(b, a % b);
2
Q
Least Common Multiple using Greatest Common Divisor
A
Least_common_multiple#Using_the_greatest_common_divisor
// const lcm = (a, b) => a * b / gcd(a, b);
3
Q
Using LCM with Multiple Numbers (reduce function)
A
// // LCM of multiple numbers
// return range.reduce((multiple, curr) => lcm(multiple, curr));