Cody

Problem 1472. nth Rational Number

Solution 885168

Submitted on 3 May 2016 by William
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x = 6; y_correct = [1 3]; assert(isequal(cantor_index2rational(x),y_correct))

s = 3 n1 = 6

2   Pass
x = 385; y_correct = [22 7]; assert(isequal(cantor_index2rational(x),y_correct))

s = 28 n1 = 406

3   Pass
x=108924; y_correct = [355 113]; assert(isequal(cantor_index2rational(x),y_correct))

s = 467 n1 = 109278

4   Pass
x = 206; y_correct = [5 16]; assert(isequal(cantor_index2rational(x),y_correct))

s = 20 n1 = 210

5   Pass
x = 2060; y_correct = [21 44]; assert(isequal(cantor_index2rational(x),y_correct))

s = 64 n1 = 2080

6   Pass
x = 20604; y_correct = [103 101]; assert(isequal(cantor_index2rational(x),y_correct))

s = 203 n1 = 20706

7   Pass
x = 20704; y_correct = [3 201]; assert(isequal(cantor_index2rational(x),y_correct))

s = 203 n1 = 20706

8   Pass
x = 205704; y_correct = [58 584]; assert(isequal(cantor_index2rational(x),y_correct))

s = 641 n1 = 205761

9   Pass
x = 2085704; y_correct = [200 1843]; assert(isequal(cantor_index2rational(x),y_correct))

s = 2042 n1 = 2085903

10   Pass
x = 20851704; y_correct = [4408 2051]; assert(isequal(cantor_index2rational(x),y_correct))

s = 6458 n1 = 20856111

11   Pass
x = 290851704; y_correct = [23437 683]; assert(isequal(cantor_index2rational(x),y_correct))

s = 24119 n1 = 290875140

Suggested Problems

More from this Author10

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!