Problem 60486. Compute Farey sequences
Problem statement
The Farey sequence of order n consists of fractions between 0 and 1 expressed in reduced form in increasing order and with no denominator greater than n. For example, the Farey sequence of order 3 is {0/1, 1/3, 1/2, 2/3, 1/1}.
Write a function to compute the Farey sequence of order n. Put the numerators in the first row of a two-row matrix and denominators in the second row.
Further comments
Farey sequences are connected to Stern-Brocot trees, but unlike some other problems of mine (e.g., CP 59791 and 60311), this one was not inspired by a problem of minnolina’s. Instead it arose out of reading The Riemann Hypothesis: The Greatest Unsolved Problem in Mathematics by Karl Sabbagh. Geologist John Farey noted, in a half-page 1816 paper in Philosophical Magazine, a relationship between a fraction in the sequence and the fractions to its left and right. In discussing the connection between the Riemann hypothesis and Farey sequences, Sabbagh writes that, mathematician G.H. Hardy “said, somewhat cruelly:
Just once in his life Mr. Farey rose above mediocrity, and made an original observation. He did not understand very well what he was doing, and he was too weak a mathematician to prove the quite simple theorem he had discovered. It is evident also that he did not consider his discovery…at all important…He had obviously no idea that this casual letter was the one event of real importance in his life. We may be tempted to think that Farey was very lucky; but a man who has made an observation that has escaped Fermat and Euler deserves any luck that comes his way.”
Stunned by this mean-spirited statement—which Hardy read in a 1928 lecture in New York City, I decided to write a problem on the sequences named for Farey.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers8
Suggested Problems
-
Find the peak 3n+1 sequence value
2498 Solvers
-
3151 Solvers
-
How to find the position of an element in a vector without using the find function
2728 Solvers
-
396 Solvers
-
Determine Whether an array is empty
775 Solvers
More from this Author279
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!