Cody

Solution 127323

Submitted on 13 Aug 2012 by James
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))

y = [] x = 7.0625 x = 15.9966 x = 1.0034 x = 292.6346 x = 1.5758 x = 1.7367 x = 1.3575 x = 2.7974 x = 1.2542 x = 3.9346 x = 1.0699 x = 14.3004 x = 3.3287 x = 3.0425 x = 23.5323 x = 1.8788 x = 1.1380 x = 7.2483 x = 4.0281 x = 35.6292 x = 1.5892 x = 1.6972 x = 1.4343 x = 2.3028 x = 3.3026 x = 3.3045 x = 3.2843 x = 3.5171 x = 1.9340 x = 1.0706 x = 14.1603 x = 6.2398 x = 4.1699 x = 5.8870 x = 1.1274 x = 7.8478 x = 1.1795 x = 5.5703 x = 1.7534 x = 1.3274 x = 3.0544 x = 18.3718 x = 2.6897 x = 1.4500 x = 2.2223 x = 4.4974 x = 2.0104 x = 96.4358 x = 2.2946 x = 3.3946

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

y = [] x = Inf

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

y = [] x = 5.0000 x = 1.0000 x = 2.2518e+14

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))

y = [] x = 3.5250 x = 1.9048 x = 1.1052 x = 9.5052 x = 1.9796 x = 1.0208 x = 48.0000