applets.

Gear Maths

← All apps

About Gear Maths

The lowest common multiple (LCM) and highest common factor (HCF, also called the greatest common divisor) as things you can see. Set the teeth on two gears (5 to 120 each) and press TURN. One tooth of the first gear and the gap it sits in on the second are painted red. The gears turn until the red marks meet again, which happens after exactly LCM teeth have gone past; the counters show how many times each gear went round. With a third gear there's a blue pair of marks too, and everything is back where it started after the LCM of all three. FINISH jumps to the end, RESET goes back to the start; Space turns or pauses. COPY LINK copies a link that opens with these gears.

The drawing beside the rig has four sheets: EUCLID (his algorithm as a rectangle cut into squares), FACTORS (prime factor trees and a Venn diagram), RACE (counting up against Euclid, on numbers as big as you like) and MACHINES (why real gear makers care).

THE STORY

This app grew from a Python program, Lowest Common Multiplier, which uses what we'll call the counting-up method: it starts at the larger number and counts up one at a time until both numbers divide it, then prints how many times each goes in. That always works, but it can take a very long time: for two large numbers with nothing in common it has to count almost all the way to their product. The RACE sheet shows how long.

The fast way is about 2,300 years old. Book VII of Euclid's Elements (around 300 BC) finds the greatest common measure of two numbers by taking the smaller from the larger over and over. Donald Knuth, in The Art of Computer Programming, called it the granddaddy of all algorithms, the oldest nontrivial one still in use. In 1844 Gabriel Lamé proved it never needs more than five times as many steps as the smaller number has digits; the worst cases are neighbouring Fibonacci numbers (89 and 55 take 9 steps). Once you have the HCF, the LCM is one sum away: a × b ÷ HCF.

Every whole number above 1 breaks into primes in only one way (the fundamental theorem of arithmetic; Carl Friedrich Gauss gave the first complete proof in 1801). So the HCF is the primes both numbers share and the LCM is every prime either one needs, which is what the Venn diagram (John Venn, 1880) shows.

HOW IT WORKS

Two meshing gears move the same number of teeth past the point where they touch, so after t teeth a gear with a teeth has turned t ÷ a times. Its mark is back where it started whenever t is a multiple of a, so both marks are back together at the first t that is a multiple of both: the LCM. Then the gear with a teeth has turned LCM ÷ a times, the last two lines of that program.

The teeth are drawn with the involute shape nearly every real gear uses (20° pressure angle): the curve traced by the end of a string unwound from a circle. Two involute teeth push on each other along one straight line, so the gears turn smoothly. Leonhard Euler worked the shape out for gears in the 18th century.

On the RACE sheet the numbers of checks are worked out, not counted: counting up tries every number from the larger one up to the LCM, so it makes LCM − larger + 1 checks. Pressing RACE does run the counting-up loop for real in this browser, for up to 8 seconds, to time it.

FURTHER WATCHING AND READING

● red marks meet every 168 teeth
TEETH PASSEDof 168same for every gear
GEAR A TURNSof 4
GEAR B TURNSof 3
GEAR C TURNSof 1

SPEED