Farey Sequence Calculator
Introduction to Farey sequences and this calculator
Farey sequences are one of the cleanest places where simple fractions suddenly reveal deep structure. For a chosen order n, the Farey sequence Fn lists every reduced fraction between 0 and 1 whose denominator does not exceed n, and it lists them in increasing order. That sounds modest at first, but the output is surprisingly rich. You can see how rational numbers fill the unit interval, how neighboring fractions relate to one another, and how quickly the list becomes dense as the denominator limit grows.
This Farey Sequence Calculator helps because building the list by hand is easy for small orders and tedious for larger ones. Once you get past n = 5 or 6, it becomes very easy to skip a valid fraction, accidentally include a nonreduced one such as 2/4, or put two nearby terms in the wrong order. The calculator removes that bookkeeping burden. You supply the order, and the page returns the full ordered sequence together with its length so you can focus on the pattern instead of the manual sorting.
Farey sequences show up in classroom work on fractions, in elementary number theory, and in the broader idea of rational approximation. They are useful whenever you want a complete catalog of “simple” fractions up to a denominator cap. This page therefore does two jobs at once: it gives you the exact list for a chosen order, and it explains what the order means, why adjacent terms obey a special determinant rule, and how to interpret the output without guessing.
What problem does this Farey sequence calculator solve?
This Farey sequence calculator solves the specific problem of enumerating all reduced fractions from 0 to 1 with denominator at most n, in strictly increasing order. In other words, it answers the question, “If I limit myself to denominators no larger than this value, what are all the distinct rational numbers I can make inside the unit interval?”
That is more useful than it may first appear. Students often confuse the order with the number of terms, but the order is really a denominator ceiling. Others expect unreduced fractions to remain in the list, even though 2/4 and 1/2 represent the same rational number and Farey sequences keep only the reduced form. A third common source of confusion is spacing: the terms are not equally spaced decimals. They are ordered by value, but the gaps shrink and widen depending on which reduced fractions are available at that denominator limit. The calculator makes all of those rules visible in one result.
If you are exploring rational approximations, the tool is also a quick way to see which simple fractions sit near a target decimal. Instead of searching a table or generating candidate fractions yourself, you can produce the full list and inspect the neighborhood around the value you care about. That makes the calculator practical for both instruction and quick reference.
How to use the Farey sequence calculator
This Farey sequence calculator has one main input, so the workflow is straightforward. Enter a positive integer order n, click Generate, and the results area will display the full sequence Fn as a comma-separated list. The page also shows the number of terms, which is a helpful cross-check if you already know what length to expect.
For most first-time users, starting with a small order such as 4, 5, or 6 is best. Those cases are short enough to read with your eyes, yet rich enough to show the underlying pattern. Once you are comfortable, increase n and notice how the number line fills with more and more distinct reduced fractions. The copy button becomes useful at that stage because it lets you move the sequence into notes, homework, or a spreadsheet without retyping it.
- Enter a positive integer for Farey Order (n).
- Click Generate to build the sequence.
- Read the length first, then scan the ordered list from 0/1 to 1/1.
- Use Copy Sequence if you want to save or share the result.
If the page reports that the order must be a positive integer, the input is not a whole number or is below 1. If the page warns that the chosen order is too large to display comfortably, reduce the order and rerun the calculation. That practical limit keeps the output readable and the page responsive.
Inputs: choosing the Farey order n
This Farey sequence calculator asks only for the order n, but that single value carries all of the mathematical meaning. The order tells the algorithm the largest denominator it is allowed to use. If you enter n = 8, then 3/7 is eligible because its denominator is 7, while 4/9 is not eligible because its denominator is 9. Among eligible fractions, only reduced forms survive, so 3/6 is excluded even though 6 is within the limit; it reduces to 1/2 and therefore does not appear as a separate term.
As n increases, two things happen at once. First, the sequence gets longer because more denominators are allowed. Second, many of the new fractions land between fractions that were already present, so the visual gaps on the number line get smaller. That is why high orders feel dramatically denser than low orders even if you increase n by only a little.
In practice, choose an order that matches the level of detail you need. If you simply want a teaching example, n = 5 is excellent. If you want a denser catalog of rational approximations, use a larger order. Just remember that the sequence length grows quickly, so a large denominator ceiling produces a very long visible list.
Formulas for Farey sequence generation
Farey sequence generation starts from a precise membership rule. A fraction a/b belongs to Fn when it lies between 0 and 1, is written in lowest terms, and has denominator b no greater than n. Once those fractions are collected, they are sorted by value. The remarkable feature is that consecutive terms are not arbitrary neighbors. If a/b and c/d are adjacent in a Farey sequence, then they satisfy a determinant relation that certifies how tightly packed they are.
That identity is one reason Farey sequences are so elegant. It tells you that neighboring terms are separated in the strongest possible way compatible with reduced fractions and the denominator bound. The sequence length also has a compact formula involving Euler’s totient function, which counts how many numerators are relatively prime to a given denominator.
For example, when n = 5, the length is 1 + φ(1) + φ(2) + φ(3) + φ(4) + φ(5) = 1 + 1 + 1 + 2 + 2 + 4 = 11. That matches the full list shown in the worked example below. The JavaScript on this page generates the sequence directly instead of testing every possible fraction, and it does so using the standard next-term recurrence for neighboring terms.
If you prefer to think about calculators abstractly, this page also fits the general “inputs to output” structure shown below. Those generic formulas are preserved here because they describe the high-level idea of turning one or more inputs into a computed result, even though this particular calculator uses a concrete Farey-specific algorithm rather than a weighted engineering total.
On this page, the only real input is the order n, and the output is the ordered list of valid reduced fractions. Even so, the same habit applies: know what the input means, know what constraints are enforced, and then read the result in the right mathematical context.
Worked example: building F5 step by step
This worked example uses the Farey sequence of order 5 because it is large enough to be interesting but still small enough to inspect manually. The allowed denominators are 1, 2, 3, 4, and 5. From those denominators, we keep only fractions between 0 and 1 that are in lowest terms. That immediately excludes forms such as 2/4 because it reduces to 1/2, which is already represented in the sequence.
The complete sequence is:
F5 = 0/1, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 1/1
Reading left to right, every term is larger than the one before it, and no eligible reduced fraction is missing. Notice a few helpful landmarks. The first interior term is 1/5 because it is the smallest positive fraction with denominator at most 5. The exact middle of the list is 1/2. Fractions such as 2/5 and 3/5 appear because they are reduced, while 2/4 does not because it is not. The list has 11 terms, which matches the totient-based length formula above.
You can also test the neighbor rule on any adjacent pair. Take 1/3 and 2/5. If a/b = 1/3 and c/d = 2/5, then bc - ad = 3·2 - 1·5 = 1. The same check works for 2/5 and 1/2 because 5·1 - 2·2 = 1. Those identities are not coincidences; they are part of what makes Farey sequences distinctive. When you run the calculator with n = 5, the output should match this list exactly.
Comparison table: how the Farey list grows with n
This Farey comparison table shows how a small increase in order can add several new fractions. It is a quick way to see why the list becomes denser faster than many people expect.
| Order n | Length |Fn| | New reduced fractions compared with the previous order | Interpretation |
|---|---|---|---|
| 4 | 7 | 0/1, 1/4, 1/3, 1/2, 2/3, 3/4, 1/1 | A short teaching example with clearly spaced terms. |
| 5 | 11 | 1/5, 2/5, 3/5, 4/5 | Order 5 inserts four new reduced fifths between existing neighbors. |
| 6 | 13 | 1/6, 5/6 | Only two sixths are new because 2/6, 3/6, and 4/6 reduce to earlier terms. |
| 7 | 19 | 1/7, 2/7, 3/7, 4/7, 5/7, 6/7 | Prime denominators often contribute many new fractions because more numerators are coprime to the denominator. |
That table captures an important intuition: not every new denominator contributes the same number of new terms. The contribution depends on how many numerators are relatively prime to that denominator. That is exactly why Euler’s totient function appears in the length formula.
How to interpret the Farey sequence result
This Farey sequence calculator returns an ordered list, so the output is not just a bag of fractions. The left end is always 0/1 and the right end is always 1/1. Every interior term is a reduced fraction between those endpoints. If a fraction you expected is missing, the usual reasons are either that its denominator is larger than the chosen order or that it reduces to a simpler fraction already present in the list.
The reported length is your fastest sanity check. If you know the rough size you expected, the length confirms that the sequence is complete before you read every term. The list itself is most useful when you are studying neighboring fractions, looking for simple approximations to a decimal in the interval from 0 to 1, or checking which new fractions appear when the denominator limit increases. The copy button is there for exactly those follow-up tasks.
One subtle point is that this page lists fractions only on the interval from 0 to 1. If you are approximating a number larger than 1, you would typically separate its integer part first and then compare the fractional part against the Farey list. That is not a flaw in the tool; it is simply the standard scope of Farey sequences.
Limitations of this Farey sequence generator
This Farey sequence generator is exact about the fractions it lists, but it still has practical boundaries. The page is designed for readable web output, not for dumping an enormous research table into a browser window. As the order grows, the number of visible terms grows quickly, and eventually the result becomes too long to scan comfortably even if the underlying math remains correct.
It is also important to remember what the calculator is and is not doing. It is generating the classical Farey sequence on [0, 1]. It is not constructing a Stern-Brocot tree, finding the best continued-fraction approximation to an arbitrary real number, or listing unreduced forms. Those are related ideas, but they answer different questions.
- Interval scope: the sequence covers fractions from 0/1 through 1/1 only.
- Reduced terms only: equivalent forms such as 2/4 are intentionally omitted.
- Integer input required: the order must be a positive whole number.
- Long-output practicality: very large orders create very long lists that are hard to read and copy.
- No symbolic proofs: the page computes and displays the sequence, but it does not prove number-theory theorems for you.
Used with those assumptions in mind, the calculator is reliable and educational. It gives you the exact ordered sequence for a chosen denominator limit, and it makes the structure behind reduced fractions much easier to see than a raw collection of decimal approximations ever could.
Farey mini-game: Sequence Sprint on the number line
This optional Farey mini-game turns the same idea into a quick reflex challenge. Your job is to steer through the next correct fraction in order while decoys and unreduced traps drift into the lane. Early waves use smaller orders, but later waves raise the denominator limit so the valid fractions crowd closer together. It is a fun way to feel, not just read about, how Farey sequences become denser as n increases.
Optional mini-game ready. Start when you want a quick, visual feel for how higher-order Farey sequences squeeze more reduced fractions into the same interval.
