Problem 1471. Index of a Rational number
The set of real numbers are infinite. They are so many that real numbers can't even be enumerated. However, unlike real numbers the set of integers is countably infinite as a mapping from 1,2,3,4,5 .... to 0,1,-1,2,-2,3,-3 can be made easily.
Surprisingly, rational Numbers are countably infinite too !!, meaning they can be enumerated. A diagonalization argument introduced by George Cantor easily shows this. Recollect that rational numbers are those numbers that can be represented in the form p/q. http://en.wikipedia.org/wiki/Rational_numbers
ex: The first ten rational numbers under this enumeration 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 this way. ie the index of 1/3 is 6
Problem 1) Next: 1472
Solution Stats
Problem Comments
-
2 Comments
Problem with test 4
I am not able to submit a solution. I get error "There was an issue submitting your solution. Remove inappropriate content. For guidelines, see About Cody"
Solution Comments
Show commentsProblem Recent Solvers116
Suggested Problems
-
3075 Solvers
-
How to find the position of an element in a vector without using the find function
2800 Solvers
-
Who has power to do everything in this world?
479 Solvers
-
6034 Solvers
-
Replace pattern 0 1 0 and 1 0 1
157 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!