Problem 1472. nth Rational Number
Return the nth rational number.
The first ten positive rational numbers under the enumeration using cantors diagonalization argument are 1/1, 2/1, 1/2, 3/1, 2/2, 1/3, 4/1, 3/2, 2/3, 1/4.
Find the index of a positive rational number enumerated in this manner, i.e. the 6th rational number is 1/3.
Solution Stats
Problem Comments
-
2 Comments
Massimo Zanetti
on 7 Oct 2016
Is that possible to have a ranking of the solutions based on their performing time? I think that the could be a method that is fast even if more sized.
Massimo Zanetti
on 10 Oct 2016
Solution
provides inexpensive method. There is only one 2nd order polynomial solution and one division.
Solution Comments
Show commentsProblem Recent Solvers151
Suggested Problems
-
Replace NaNs with the number that appears to its left in the row.
2900 Solvers
-
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
368 Solvers
-
Convert a Cell Array into an Array
1505 Solvers
-
475 Solvers
-
4462 Solvers
More from this Author10
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!