The guide
Fractions in order: why Farey neighbours always have determinant 1
List every reduced fraction up to a given denominator and a strict pattern appears: neighbours cross-multiply to 1, new terms are mediants, and the length is a totient sum.
- 33 terms in F10, the fractions up to denominator 10
- 12,233 terms in F200, the longest list on the page
- 1/15 gap between the neighbours 1/3 and 2/5
- 3/8 first new term between 1/3 and 2/5, arriving in F8
- 96 terms with denominator 97 in F100
Read the full guide Fold the guide
Write down every fraction between 0 and 1 that is already in lowest terms and has a denominator of at most 5. Sort them. You get 0/1, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5 and 1/1. That list of eleven terms is the Farey sequence of order 5, written F5.
It looks like an exercise in sorting. It turns out to be one of the tidiest objects in number theory, because every question you ask about it has an exact answer, and the answers connect. A chatbot that is asked for such a list tends to fail in three ways. It drops a fraction, repeats one that is not in lowest terms, or reports the wrong length. All three are easy to catch once you know the rules below.
The name and the surprise
The sequences are named for John Farey, an English geologist who wrote a four-paragraph note on them in the Philosophical Magazine in 1816. He had noticed the pattern while looking through tables of decimal quotients. His observation was that each fraction in the list equals the fraction made by adding the numerators and adding the denominators of its two neighbours.
Farey did not prove it. He asked the magazine’s readers whether the property was already known and whether it had an easy proof. Cauchy read a French translation and supplied the proof in the same year. Credit then went to the wrong man. Charles Haros had published similar results in 1802, and neither Farey nor Cauchy knew of it. The sequence carries Farey’s name through a historical accident, as Wikipedia puts it, and the pattern is worth more than the argument about who saw it first.
Neighbours, determinants and mediants
Take two fractions a/b and c/d. Their mediant is (a+c)/(b+d): add the tops, add the bottoms. It is the classic freshman mistake for adding fractions, and it is also a useful operation. The mediant always lies strictly between the two fractions it was built from.
Now look at two neighbours in a Farey sequence. If a/b is just below c/d, then b times c minus a times d equals 1, so the gap between them is exactly 1/(bd). In F5 the neighbours 1/3 and 2/5 give 3 times 2 minus 1 times 5, which is 1, and their gap is 1/15. The reverse also holds. If a < b, c < d and bc - ad = 1, then a/b and c/d are neighbours in the Farey sequence of order max(b, d). A determinant of 1 is therefore a complete test for being neighbours.
The mediant rule follows in a few lines. Suppose p/q has neighbours a/b and c/d. Then bp - aq = 1 and qc - pd = 1. Add them, rearrange, and you get p(b+d) = q(a+c). So p/q equals (a+c)/(b+d) as a value, although the numbers a+c and b+d may be a multiple of p and q.
Here is the worked example you can reproduce on the page. In F7 the neighbours of 1/3 are 2/7 and 2/5. Check the left side: 7 times 1 minus 2 times 3 is 1. Check the right side: 3 times 2 minus 1 times 5 is 1. Add the neighbours part by part and you get 4/12, which is 4 times 1/3, so 1/3 is still their mediant before reducing.
How the list grows
Go from F5 to F6 and two terms appear, 1/6 and 5/6. Go on to F7 and six more appear. Every new term sits between two old neighbours, and it is their mediant. The question is when.
For neighbours the mediant (a+c)/(b+d) is already in lowest terms, so its denominator is b+d. It cannot exist before order b+d, and it does exist from that order on. That is the whole growth rule: the first fraction to appear between neighbours a/b and c/d is (a+c)/(b+d), and it arrives in order b+d. Between 1/3 and 2/5 the first newcomer is 3/8, in F8.
The mediant is also the simplest fraction in the gap. When two fractions have determinant 1, any fraction strictly between them has a denominator at least as large as b+d. Nothing simpler can sneak in, which is why the mediant arrives first.
This is also the link to the Stern-Brocot tree, which builds all positive rationals by taking mediants. The tree includes every mediant at each step, not only the ones whose denominator equals the step number. Its left half, the fractions from 0 to 1, is called the Farey tree. Achille Brocot was a French clockmaker who used the tree to pick gear ratios close to a target value.
To generate the list without any sorting, start from 0/1 and 1/n. Given two consecutive terms a/b and c/d, the next one is (kc - a)/(kd - b), where k is the whole number part of (n+b)/d. The step is exact, uses only integers, and ends at 1/1. It is one way to build the list, and the tool checks it against a plain brute-force listing of every reduced fraction.
Counting the terms
How long is F_n? Going from F(n-1) to F(n) adds one fraction for each whole number below n that shares no factor with n, and the count of those is Euler’s totient function, written phi(n). It counts the whole numbers up to n that are coprime to n, so phi(7) is 6 and phi(97) is 96.
Starting from F1, which has two terms, the length is 1 plus the sum of phi(1) up to phi(n). For n = 10 the totients are 1, 1, 2, 2, 4, 2, 6, 4, 6 and 4, which add to 32, so F10 has 33 terms. The integer sequence of these lengths is listed in the On-Line Encyclopedia of Integer Sequences, and 33 is its value at 10. The running sums of the totients that feed it have an entry of their own.
There is a second route. Define the Moebius function mu so that mu(1) is 1, mu(d) is (-1) raised to the number of prime factors when d has no repeated prime, and 0 otherwise. Then the length is half of 3 plus the sum over d of mu(d) times the square of the whole number part of n/d.
For n = 10 the nonzero terms are 100, -25, -9, -4, 1, -1 and 1. They add to 63, and half of 66 is 33 again. Two quite different formulas give the same count, and the page shows both beside the number of terms in the list itself.
The count by denominator is just as direct. A fraction with denominator k in lowest terms has a numerator coprime to k, so there are phi(k) of them. In F100 there are 96 fractions with denominator 97, because 97 is prime. At the top of the page’s range the length reaches 12,233 terms for order 200, and in general it grows like 3n squared over pi squared.
Why it matters, and what the page does not do
Farey sequences are a map of the rational numbers by simplicity. Pick any real number between 0 and 1 and it lands in a gap between two neighbours of F_n. That gap is 1/(bd) wide, where b+d is more than n, so no fraction with a denominator up to n lies strictly inside it.
Dirichlet’s approximation theorem says that for any real number there is a fraction with denominator at most N whose distance, scaled by that denominator, is at most 1 over N+1. Farey neighbours give a short proof. If both ends of the gap were farther away than that, the gap would be wider than 1/(bd) allows, because b+d is at least n+1.
Take 0.3 in F5. It sits between 1/4 and 1/3, and its distance to 1/3 is 1/30, which is under the allowed 1/18. The sharper Hurwitz theorem goes further. For every irrational number there are infinitely many fractions within 1/(root 5 times q squared), and the golden ratio shows that root 5 cannot be improved.
Geometry sees the same structure. Two Ford circles, one standing on each fraction, touch exactly when the fractions have determinant 1 in absolute value, which is the neighbour rule drawn as tangent circles. The sequences also appear in equivalent forms of the Riemann hypothesis, one proved by Franel in 1924 and another noted by Landau just after.
The tool lists orders 1 to 200 and states the number of terms before it builds the list. Typed fractions are limited to 200 characters and are reduced exactly with big-integer arithmetic. The heavy work runs in a background worker so the page stays responsive.
What it does not do matters as much. It does not expand fractions into continued fractions, walk down the Stern-Brocot tree, approximate a real number, or prove anything. A chatbot can still be wrong about any of these, which is why each result is checked against a second route rather than trusted.
Sources
Every source consulted for this guide. Links checked November 10, 2026.
- Farey sequence - Wikipedia Wikipedia (CC BY-SA 4.0)
- Mediant (mathematics) - Wikipedia Wikipedia (CC BY-SA 4.0)
- Euler's totient function - Wikipedia Wikipedia (CC BY-SA 4.0)
- Mobius function - Wikipedia Wikipedia (CC BY-SA 4.0)
- Stern-Brocot tree - Wikipedia Wikipedia (CC BY-SA 4.0)
- Ford circle - Wikipedia Wikipedia (CC BY-SA 4.0)
- Dirichlet's approximation theorem - Wikipedia Wikipedia (CC BY-SA 4.0)
- Hurwitz's theorem (number theory) - Wikipedia Wikipedia (CC BY-SA 4.0)
- John Farey (1766 - 1826) - Biography MacTutor History of Mathematics, University of St Andrews (CC BY-SA 4.0)
- A005728 - Number of fractions in Farey series of order n The On-Line Encyclopedia of Integer Sequences (CC BY-SA 4.0)
- A002088 - Sum of totient function The On-Line Encyclopedia of Integer Sequences (CC BY-SA 4.0)
- BigInt - JavaScript | MDN MDN Web Docs (Creative Commons licence)
- Web Workers API - Web APIs | MDN MDN Web Docs (Creative Commons licence)