Cody

Solution 423188

Submitted on 27 Mar 2014 by Jan Orwat
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 = 3 y = 3 7 y = 3 7 15 y = 3 7 15 1 y = 3 7 15 1 292 y = 3 7 15 1 292 1 y = 3 7 15 1 292 1 1 y = 3 7 15 1 292 1 1 1 y = 3 7 15 1 292 1 1 1 2 y = 3 7 15 1 292 1 1 1 2 1 y = 3 7 15 1 292 1 1 1 2 1 3 y = 3 7 15 1 292 1 1 1 2 1 3 1 y = 3 7 15 1 292 1 1 1 2 1 3 1 14 y = 3 7 15 1 292 1 1 1 2 1 3 1 14 3 y = 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 y = 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Column 17 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 18 1 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 19 1 1 7 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 20 1 1 7 4 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 21 1 1 7 4 35 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 22 1 1 7 4 35 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 23 1 1 7 4 35 1 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 24 1 1 7 4 35 1 1 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 25 1 1 7 4 35 1 1 1 2 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 26 1 1 7 4 35 1 1 1 2 3 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 27 1 1 7 4 35 1 1 1 2 3 3 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 28 1 1 7 4 35 1 1 1 2 3 3 3 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 29 1 1 7 4 35 1 1 1 2 3 3 3 3 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 30 1 1 7 4 35 1 1 1 2 3 3 3 3 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 31 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Column 33 6 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 34 6 4 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 35 6 4 5 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 36 6 4 5 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 37 6 4 5 1 7 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 38 6 4 5 1 7 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 39 6 4 5 1 7 1 5 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 40 6 4 5 1 7 1 5 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 41 6 4 5 1 7 1 5 1 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 42 6 4 5 1 7 1 5 1 1 3 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 43 6 4 5 1 7 1 5 1 1 3 18 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 44 6 4 5 1 7 1 5 1 1 3 18 2 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 45 6 4 5 1 7 1 5 1 1 3 18 2 1 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 46 6 4 5 1 7 1 5 1 1 3 18 2 1 2 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 47 6 4 5 1 7 1 5 1 1 3 18 2 1 2 4 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 48 6 4 5 1 7 1 5 1 1 3 18 2 1 2 4 2 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 48 6 4 5 1 7 1 5 1 1 3 18 2 1 2 4 2 Column 49 96 y = Columns 1 through 16 3 7 15 1 292 1 1 1 2 1 3 1 14 3 3 23 Columns 17 through 32 1 1 7 4 35 1 1 1 2 3 3 3 3 1 1 14 Columns 33 through 48 6 4 5 1 7 1 5 1 1 3 18 2 1 2 4 2 Columns 49 through 50 96 2

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

y = 1

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

y = 5 y = 5 4 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))

y = 2 y = 2 3 y = 2 3 1 y = 2 3 1 1 y = 2 3 1 1 9 y = 2 3 1 1 9 1 y = 2 3 1 1 9 1 1

Suggested Problems