Cody

Solution 126371

Submitted on 10 Aug 2012 by Khaled Hamed
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))

s = 3 x = 7.0625 s = 7 x = 15.9966 s = 15 x = 1.0034 s = 1 x = 292.6346 s = 292 x = 1.5758 s = 1 x = 1.7367 s = 1 x = 1.3575 s = 1 x = 2.7974 s = 2 x = 1.2542 s = 1 x = 3.9346 s = 3 x = 1.0699 s = 1 x = 14.3004 s = 14 x = 3.3287 s = 3 x = 3.0425 s = 3 x = 23.5323 s = 23 x = 1.8788 s = 1 x = 1.1380 s = 1 x = 7.2483 s = 7 x = 4.0281 s = 4 x = 35.6292 s = 35 x = 1.5892 s = 1 x = 1.6972 s = 1 x = 1.4343 s = 1 x = 2.3028 s = 2 x = 3.3026 s = 3 x = 3.3045 s = 3 x = 3.2843 s = 3 x = 3.5171 s = 3 x = 1.9340 s = 1 x = 1.0706 s = 1 x = 14.1603 s = 14 x = 6.2398 s = 6 x = 4.1699 s = 4 x = 5.8870 s = 5 x = 1.1274 s = 1 x = 7.8478 s = 7 x = 1.1795 s = 1 x = 5.5703 s = 5 x = 1.7534 s = 1 x = 1.3274 s = 1 x = 3.0544 s = 3 x = 18.3718 s = 18 x = 2.6897 s = 2 x = 1.4500 s = 1 x = 2.2223 s = 2 x = 4.4974 s = 4 x = 2.0104 s = 2 x = 96.4358 s = 96 x = 2.2946 s = 2 x = 3.3946

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

s = 1

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

s = 5 x = 5.0000 s = 4 x = 1.0000 s = 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))

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