Farey Sequence Calculator

List all reduced fractions between zero and one with denominator up to n.

Math and PercentUpdated 2026-11-202 min read
Farey Sequence Calculator
Whole number from 1 to 50. Larger orders produce long lists.
Farey sequence
...
Number of terms...
Order used...

What it does

The Farey sequence of order n is the sorted list of all fractions between zero and one that are in lowest terms and have denominator no larger than n. It starts with 0/1 and ends with 1/1.

Northeastern University number theory notes introduce Farey sequences as a tool for rational approximation. The idea is to arrange nearby rationals in order and see where a real number falls between them.

A University of Edinburgh project explores the same sequences and proves properties such as the neighbour rule, where consecutive fractions a over b and c over d satisfy b c minus a d equals one.

This tool generates the sequence for an order up to 50, sorts the fractions by value and reports how many terms appear.

Farey sequences connect to continued fractions, Ford circles and approximation of irrational numbers.

How to use

  1. Enter an order from 1 to 50.
  2. Read the sequence in ascending order in the main result.
  3. Check the number of terms, which grows roughly as n squared.
  4. Try order 5 to reproduce the worked example.
  5. Look at neighbouring fractions to test the determinant property.
  6. Increase n gradually because long sequences are hard to scan.

Formula

F(n) = { a/b : 0 <= a <= b <= n, gcd(a,b) = 1 }, sorted by a/b. Count = 1 + sum of phi(k) for k = 1 to n.
n
The order, the largest allowed denominator.
a/b
A reduced fraction in the sequence.
gcd
Greatest common divisor, used to keep only reduced fractions.
phi
Euler's totient function, counting coprime residues.

The engine checks gcd of numerator and denominator for every candidate, then sorts using cross multiplication so no floating point rounding affects the order.

Worked example

Example: order 5

Enter n = 5.

  1. Start with the endpoints 0/1 and 1/1.
  2. Include every reduced fraction with denominator up to 5.
  3. Sorting by value gives 0/1, 1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5 and 1/1.
  4. There are 11 terms in total.
  5. Check neighbours 1/3 and 2/5: 2 x 3 - 1 x 5 = 1.
  6. The tool reports the full sequence and terms 11.

Reference table

Farey sequence counts for small orders
OrderNumber of termsLast interior fraction
120/1
352/3
5114/5
10339/10

Limits

  • Order is capped at 50 to keep printed output manageable.
  • The tool lists fractions rather than plotting them.
  • It does not compute Ford circles or continued fractions.
  • Very long sequences may wrap in the result box.

Common mistakes

  • Including unreduced fractions such as 2/4.
  • Allowing denominators larger than the chosen order.
  • Sorting by denominator rather than by value.
  • Forgetting the endpoints 0/1 and 1/1.
  • Assuming the count grows linearly with n.

Try it yourself

Quick checks. Answers sit tucked under each question.

List the Farey sequence of order 3.

0/1, 1/3, 1/2, 2/3, 1/1, five terms.

How many terms are in order 5?

11 terms.

Why must fractions be reduced?

The sequence lists each rational number once, in lowest terms.

Questions

What is a Farey sequence?

An ordered list of reduced fractions between zero and one with bounded denominators.

Who is it named after?

John Farey, who observed the pattern in 1816.

What is the neighbour property?

Consecutive fractions a/b and c/d satisfy b c minus a d equals one.

How many terms are there?

One plus the sum of Euler's totient from 1 to n.

Where is it useful?

In rational approximation, continued fractions and number theory.

Does the tool plot the fractions?

No. It prints the ordered list.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.