Cody

# Problem 1289. Evaluating continued fractions

Solution 207432

Submitted on 22 Feb 2013
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   Fail
%% c=ones(1,40); x=(1+sqrt(5))/2; y=contfrac(c); assert(abs(y-x)<1e-15)

Error: Index exceeds matrix dimensions.

2   Fail
%% c=[3 7 15 1 292 1 1 1 2 1 3 1 14]; x=pi; y=contfrac(c); assert(abs(y-x)<1e-15)

Error: Index exceeds matrix dimensions.

3   Fail
%% c=[3 7 15 1]; x=355/113; y=contfrac(c); assert(abs(y-x)<1e-15)

Error: Index exceeds matrix dimensions.

4   Fail
%% c=[1 1 1 3 1 5 1 7 1 9 1 11 1 13 1 15 1 17 1 19 1; 2 1 2 1 1 4 1 1 6 1 1 8 1 1 10 1 1 12 1 1 14]; x=[tan(1);exp(1)]; y=contfrac(c); assert(max(abs(y-x))<1e-15)

Error: Attempted to access c(1); index out of bounds because numel(c)=0.

5   Fail
%% c=(1:9)'*[1 2*ones(1,20)]; x=sqrt([2;5;10;17;26;37;50;65;82]); y=contfrac(c); assert(max(abs(y-x))<1e-15)

Error: Attempted to access c(1); index out of bounds because numel(c)=0.