Cody

Solution 127667

Submitted on 14 Aug 2012 by @bmtran (Bryant Tran)
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 = pi; n = 50; y_correct = [3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 ... 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 6 4 5 1 7 1 5 1 1 3 18 2 1 2 4 2 96 2]; assert(isequal(finite_continued_fraction(x,n),y_correct))

x = 7.0625 y = 3 7 x = 15.9966 y = 3 7 15 x = 1.0034 y = 3 7 15 1 x = 292.6346 y = 3 7 15 1 292 x = 1.5758 y = 3 7 15 1 292 1 x = 1.7367 y = 3 7 15 1 292 1 1 x = 1.3575 y = 3 7 15 1 292 1 1 1 x = 2.7974 y = 3 7 15 1 292 1 1 1 2 x = 1.2542 y = 3 7 15 1 292 1 1 1 2 1 x = 3.9346 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Column 11 3 x = 1.0699 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 12 3 1 x = 14.3004 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 13 3 1 14 x = 3.3287 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 14 3 1 14 3 x = 3.0425 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 15 3 1 14 3 3 x = 23.5323 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 16 3 1 14 3 3 23 x = 1.8788 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 17 3 1 14 3 3 23 1 x = 1.1380 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 18 3 1 14 3 3 23 1 1 x = 7.2483 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 19 3 1 14 3 3 23 1 1 7 x = 4.0281 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 x = 35.6292 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Column 21 35 x = 1.5892 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 22 35 1 x = 1.6972 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 23 35 1 1 x = 1.4343 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 24 35 1 1 1 x = 2.3028 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 25 35 1 1 1 2 x = 3.3026 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 26 35 1 1 1 2 3 x = 3.3045 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 27 35 1 1 1 2 3 3 x = 3.2843 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 28 35 1 1 1 2 3 3 3 x = 3.5171 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 29 35 1 1 1 2 3 3 3 3 x = 1.9340 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 x = 1.0706 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Column 31 1 x = 14.1603 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 32 1 14 x = 6.2398 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 33 1 14 6 x = 4.1699 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 34 1 14 6 4 x = 5.8870 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 35 1 14 6 4 5 x = 1.1274 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 36 1 14 6 4 5 1 x = 7.8478 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 37 1 14 6 4 5 1 7 x = 1.1795 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 38 1 14 6 4 5 1 7 1 x = 5.5703 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 39 1 14 6 4 5 1 7 1 5 x = 1.7534 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 40 1 14 6 4 5 1 7 1 5 1 x = 1.3274 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 40 1 14 6 4 5 1 7 1 5 1 Column 41 1 x = 3.0544 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 40 1 14 6 4 5 1 7 1 5 1 Columns 41 through 42 1 3 x = 18.3718 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 40 1 14 6 4 5 1 7 1 5 1 Columns 41 through 43 1 3 18 x = 2.6897 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 40 1 14 6 4 5 1 7 1 5 1 Columns 41 through 44 1 3 18 2 x = 1.4500 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 23 1 1 7 4 Columns 21 through 30 35 1 1 1 2 3 3 3 3 1 Columns 31 through 40 1 14 6 4 5 1 7 1 5 1 Columns 41 through 45 1 3 18 2 1 x = 2.2223 y = Columns 1 through 10 3 7 15 1 292 1 1 1 2 1 Columns 11 through 20 3 1 14 3 3 ...

2   Pass
%% x = 1; n = 10; y_correct = 1; assert(isequal(finite_continued_fraction(x,n),y_correct))

x = Inf y = 1 Inf x = NaN y = 1 Inf NaN x = NaN y = 1 Inf NaN NaN x = NaN y = 1 Inf NaN NaN NaN x = NaN y = 1 Inf NaN NaN NaN NaN x = NaN y = 1 Inf NaN NaN NaN NaN NaN x = NaN y = 1 Inf NaN NaN NaN NaN NaN NaN x = NaN y = 1 Inf NaN NaN NaN NaN NaN NaN NaN x = NaN y = 1 Inf NaN NaN NaN NaN NaN NaN NaN NaN

3   Pass
%% x = 5.2; n = 5; y_correct = [5 4 1]; assert(isequal(finite_continued_fraction(x,n),y_correct))

x = 5.0000 y = 5 4 x = 1.0000 y = 5 4 1

4   Pass
%% x = 15625/6842; n = 7; y_correct = [2 3 1 1 9 1 1]; assert(isequal(finite_continued_fraction(x,n),y_correct))

x = 3.5250 y = 2 3 x = 1.9048 y = 2 3 1 x = 1.1052 y = 2 3 1 1 x = 9.5052 y = 2 3 1 1 9 x = 1.9796 y = 2 3 1 1 9 1 x = 1.0208 y = 2 3 1 1 9 1 1