Farey Sequence of Order n
List the reduced fractions from zero to one in increasing order with denominators at most n; order is capped at 300 to bound the output size.
Description
A Farey sequence of order n lists reduced fractions from zero to one whose denominators do not exceed n.
A Farey sequence of order n lists reduced fractions from zero to one whose denominators do not exceed n. Neighbor relations allow the sequence to be generated already sorted.1
The tool returns fractions. The indexing and output conventions below determine how to read these values.
When to use Farey Sequence of Order n
Use this for the following task: List the reduced fractions from zero to one in increasing order with denominators at most n; order is capped at 300 to bound the output size. Use the input and output conventions below to reproduce the intended mathematical quantity.
How to use Farey Sequence of Order n and understand its results
- Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
- Enter order according to the field table, then run the tool.
- Read fractions. Use the stated units, indexing and interpretation of the numerical result.
- Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| order | Farey order (resource limit 300) | integer; minimum 1; maximum 300 | Required |
Start at 0/1 and 1/n, repeatedly append the current fraction and update the neighbor pair. Return integer numerator/denominator objects through 1/1.
next fraction = (k×c−a)/(k×d−b), k=floor((n+b)/d), after neighbors a/b,c/d The symbols and boundary conditions refer to the supplied fields and the implementation described above.
| Output field | Meaning | Value type |
|---|---|---|
| fractions | Ordered reduced fractions | list of object |
{
"input": {
"order": 4
},
"output": {
"fractions": [
{
"numerator": 0,
"denominator": 1
},
{
"numerator": 1,
"denominator": 4
},
{
"numerator": 1,
"denominator": 3
},
{
"numerator": 1,
"denominator": 2
},
{
"numerator": 2,
"denominator": 3
},
{
"numerator": 3,
"denominator": 4
},
{
"numerator": 1,
"denominator": 1
}
]
}
} Limitations and assumptions
The order is in 1..300 to bound output size. The tool generates the full sequence, without arbitrary endpoints or unreduced input fractions.
Use the declared integer bounds and string formats. Large exact outputs remain decimal strings; numerical approximations use ordinary floating-point arithmetic. A rejected input is different from a valid zero count or false membership flag.
Alternative or Complementary methods
Choose Stern–Brocot Neighbor Mediant when you need its operation: Insert the reduced mediant between ordered nonnegative Stern–Brocot neighbors satisfying b·c−a·d=1, including the boundary pair 0/1 and 1/0. Choose Continued Fraction Convergents for the complementary operation: Build all exact rational convergents of a finite simple continued fraction with an integral first coefficient and positive remaining coefficients.
Background reference: OEIS A005728.
References
-
OEIS A005728 — OEIS Foundation
Similar or alternative tools
- Stern–Brocot Neighbor Mediant
Insert the reduced mediant between ordered nonnegative Stern–Brocot neighbors satisfying b·c−a·d=1, including the boundary pair 0/1 and 1/0.
- Continued Fraction Convergents
Build all exact rational convergents of a finite simple continued fraction with an integral first coefficient and positive remaining coefficients.