Least common multiples predict when gears and planets line up again
Mark a line across two meshing gears and set them turning. How long until the mark lines up again? The answer is the least common multiple of their tooth counts. The same arithmetic tells you when three planets with whole-number orbital periods will return to a straight line.
The least common multiple of two nonzero integers is the smallest positive number both divide into evenly. For 4 and 6, list the multiples of each and the first number appearing in both lists is 12. Negative numbers work the same way, so 10 is the least common multiple of minus 5 and minus 2 as well as of 5 and 2. Zero causes trouble because division by zero is undefined, though some authors simply set the answer to zero whenever one input is zero.
Its most everyday job is adding fractions. To combine two twenty-firsts and one sixth, rewrite both over 42, the least common multiple of 21 and 6, giving four forty-seconds plus seven forty-seconds, or eleven forty-seconds. The shared denominator is known as the lowest common denominator.
In the gear puzzle, if one gear has m teeth and the other n, the first must turn the least common multiple of m and n divided by m times before the mark realigns, while the second turns that multiple divided by n times. For planets with orbits of l, m and n time units, starting in a line, the next alignment arrives after the least common multiple of all three, each planet having completed a whole number of laps.
Listing multiples becomes hopeless for big numbers, so there are shortcuts. One uses the greatest common divisor: multiply the numbers, take the absolute value and divide by their gcd, which the Euclidean algorithm finds quickly without factoring anything. Another relies on unique prime factorisation, the fact that every integer above 1 breaks into primes in only one way, as 90 is one 2, two 3s and one 5. Take the highest power of each prime appearing in any of the numbers and multiply them together.
Source: Least common multiple