Cody

# Problem 897. Finite Continued Fraction

Solution 126336

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

ans = 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 50 1 3 18 2 1 2 4 2 96 2

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

ans = 1

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

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

ans = 2 3 1 1 9 1 1