The Farey sequence Fₙ is every fraction in [0,1] in lowest terms with denominator at most n, listed in increasing order. Its magic: any two neighbours a/b, c/d satisfy bc - ad = 1, and the fraction that first appears between them is their mediant (a+c)/(b+d) — so the whole ordered list is generated with integer add and compare, never a floating-point sort.
Generate F₅ from 0/1 and 1/5 by the neighbour recurrence — each term computed from the previous two with integers only. Watch the ordered fractions appear, every adjacent pair with bc-ad=1: live demo
“Farey discovered the Farey sequence.” — no. Charles Haros published the construction and the neighbour property in 1802; John Farey only observed the mediant property in 1816 (with no proof), and Cauchy proved it — then attached Farey’s name. Hardy noted pointedly that Farey “is immortal because he failed to understand a theorem which Haros had proved perfectly fourteen years before.” cited
That bc - ad = 1 for neighbours is unimodularity: consecutive Farey fractions are the columns of a determinant-1 matrix, which is why the mediant is always already in lowest terms — the same integer structure the Stern-Brocot tree computes without storing. Haros 1802 / Farey 1816
On the canonical compiler the neighbour recurrence generates F₅ from the last two terms — integer arithmetic, exact order: