They used Euclid’s algorithm. Saved you a click.

Contents:

Euclid’s algorithm

When two unequal numbers are set out, and the less is continually subtracted in turn from the greater, if the number which is left never measures the one before it until a unit is left, then the original numbers are relatively prime.

Proposition VII.I, Euclid’s Elements

The original formulation is quite a mouthful, so here’s a translation to code and a viz:

A stopping problem

The modern form of this algorithm saves a few iterations and uses a mod b instead of subtractions. This is also helpful since any self-respecting mod function would throw an error when either number is not an integer. But then, what happens if one of them actually isn’t?

After two iterations, we get a rectangle with the same side proportions as the original one. Zoom in, and you’re back to square one.

Three books after describing it, Euclid says (in Prop. X.2) that if you call his gcd(a,b) with b=1 and it goes infinite, then you’ve just proved that a is irrational. Congrats.

Name dropping

In one of Plato’s dialogues, a young mathematician tells Socrates that his teacher Theodorus “was drawing some figures” to prove \(\sqrt{3},\sqrt{5}, \ldots, \sqrt{17}\) were irrational, but at that “he stopped”.

That’s everything Plato gave us to work with, but Benno Artmann had an idea for what exactly these “figures” might be…

Why did Theodorus stop at \(\sqrt{17}\) and not go for \(\sqrt{19}\)? Maybe these two facts had something to do with it:

  1. You’d need six iterations of Euclid’s algorithm to get a rectangle with side proportions you’ve seen before.
  2. Its area would be 0.000004 of the original area.