Farey Sequence Generator
The Farey sequence of order n is every fraction between 0 and 1 whose denominator is at most n, in lowest terms and in ascending order. Its striking property is local: for any two neighbours a/b and c/d, the difference bc − ad is exactly one, always. That identity is what lets each term be computed from the two before it, and it is checked here on every consecutive pair.
What this generator does
Produces the sequence with the standard next-term recurrence, so the terms arrive already ordered and already reduced. Every consecutive pair is then checked against the neighbour identity, and every reduced fraction within the order is confirmed present.
How to use this tool
- Choose an order between 2 and 40.
- Read the sequence — it always runs from 0/1 to 1/1.
- Pick any two neighbours and check the cross products differ by one.
- Increase the order and watch new fractions appear between existing neighbours.
Understanding the controls
- Order
- Between 2 and 40. The sequence length grows roughly with the square of the order, so order 40 already has nearly five hundred terms.
Common use cases
- Generating Farey sequences for a number theory exercise
- Demonstrating the mediant property between neighbouring fractions
- Teaching why every fraction appears exactly once in lowest terms
- Producing ordered fraction lists for a worksheet
- Exploring the connection to the Stern-Brocot tree
How this generator works
Given two consecutive terms, the next one follows from a short formula involving the order — no sorting, no searching and no removing duplicates. That recurrence works precisely because of the neighbour identity: consecutive terms a/b and c/d always satisfy bc − ad = 1. Before display the identity is checked on every consecutive pair, every term is confirmed to be in lowest terms and strictly increasing, and every reduced fraction within the order is confirmed to be present, so nothing has been skipped.
Randomness and fairness
Nothing here is random. Each order has exactly one Farey sequence.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Only the interval from 0 to 1 is produced, which is the standard definition; extending it to other intervals is a shift rather than new mathematics.
- The order is capped at 40 because the completeness check tests every fraction within the order.
- The sequence is shown as a flat list rather than as the Stern-Brocot tree that generates it.
- Terms are exact fractions, not decimals, which is the point but does make long sequences dense to read.
Privacy and your data
The sequence is generated in your browser and the order you choose is never transmitted, stored or included in analytics.
Related generators
- Continued Fraction GeneratorExpands any fraction into its continued fraction and lists the convergents, each proved to be the best approximation for its denominator.
- Best Rational Approximation GeneratorFinds the closest fraction to a decimal within a denominator limit, proved by testing every denominator up to that limit.
- Egyptian Fraction GeneratorExpands a fraction into distinct unit fractions by the greedy method, added back up in exact big integers to prove the sum.
- Random Fraction Range GeneratorA random fraction with numerator and denominator each up to 20.