Cody

# Problem 24. Function Iterator

Solution 555291

Submitted on 10 Jan 2015 by Lukas
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
%% noOp = @(x)x; fh2 = iterate_fcn(noOp, 50); assert(isequal(fh2(pi),pi));

fh2 = @(x)nested_function(x) nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416 nested_output = 3.1416

2   Pass

fh2 = @(x)nested_function(x) nested_output = 4 nested_output = 5 nested_output = 6 nested_output = 7 nested_output = 8 nested_output = 9 nested_output = 10 nested_output = 11 nested_output = 12 nested_output = 13

3   Pass

fh2 = @(x)nested_function(x) nested_output = 4

4   Pass
%% squarer = @(a) a^2; fh2 = iterate_fcn(squarer, 3); assert(isequal(fh2(3),6561));

fh2 = @(x)nested_function(x) nested_output = 9 nested_output = 81 nested_output = 6561

5   Pass
%% fh = @(y)sqrt(y+1); fh2 = iterate_fcn(fh,30); assert(abs(fh2(1) - (1+sqrt(5))/2) < 100*eps);

fh2 = @(x)nested_function(x) nested_output = 1.4142 nested_output = 1.5538 nested_output = 1.5981 nested_output = 1.6118 nested_output = 1.6161 nested_output = 1.6174 nested_output = 1.6179 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180 nested_output = 1.6180