Cody

Solution 2078058

Submitted on 3 Jan 2020 by Nico Noordam
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 = function_handle with value: @iterate_fcn/iter v = 3.1416 n = 49 v = 3.1416 n = 48 v = 3.1416 n = 47 v = 3.1416 n = 46 v = 3.1416 n = 45 v = 3.1416 n = 44 v = 3.1416 n = 43 v = 3.1416 n = 42 v = 3.1416 n = 41 v = 3.1416 n = 40 v = 3.1416 n = 39 v = 3.1416 n = 38 v = 3.1416 n = 37 v = 3.1416 n = 36 v = 3.1416 n = 35 v = 3.1416 n = 34 v = 3.1416 n = 33 v = 3.1416 n = 32 v = 3.1416 n = 31 v = 3.1416 n = 30 v = 3.1416 n = 29 v = 3.1416 n = 28 v = 3.1416 n = 27 v = 3.1416 n = 26 v = 3.1416 n = 25 v = 3.1416 n = 24 v = 3.1416 n = 23 v = 3.1416 n = 22 v = 3.1416 n = 21 v = 3.1416 n = 20 v = 3.1416 n = 19 v = 3.1416 n = 18 v = 3.1416 n = 17 v = 3.1416 n = 16 v = 3.1416 n = 15 v = 3.1416 n = 14 v = 3.1416 n = 13 v = 3.1416 n = 12 v = 3.1416 n = 11 v = 3.1416 n = 10 v = 3.1416 n = 9 v = 3.1416 n = 8 v = 3.1416 n = 7 v = 3.1416 n = 6 v = 3.1416 n = 5 v = 3.1416 n = 4 v = 3.1416 n = 3 v = 3.1416 n = 2 v = 3.1416 n = 1 v = 3.1416 n = 0

2   Pass
addOne = @(x)x+1; addTen = iterate_fcn(addOne, 10); assert(isequal(addTen(3),13));

fh2 = function_handle with value: @iterate_fcn/iter v = 4 n = 9 v = 5 n = 8 v = 6 n = 7 v = 7 n = 6 v = 8 n = 5 v = 9 n = 4 v = 10 n = 3 v = 11 n = 2 v = 12 n = 1 v = 13 n = 0

3   Pass
addOne = @(x)x+1; addOne2 = iterate_fcn(addOne, 1); assert(isequal(addOne2(3),4));

fh2 = function_handle with value: @iterate_fcn/iter v = 4 n = 0

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

fh2 = function_handle with value: @iterate_fcn/iter v = 9 n = 2 v = 81 n = 1 v = 6561 n = 0

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

fh2 = function_handle with value: @iterate_fcn/iter v = 1.4142 n = 29 v = 1.5538 n = 28 v = 1.5981 n = 27 v = 1.6118 n = 26 v = 1.6161 n = 25 v = 1.6174 n = 24 v = 1.6179 n = 23 v = 1.6180 n = 22 v = 1.6180 n = 21 v = 1.6180 n = 20 v = 1.6180 n = 19 v = 1.6180 n = 18 v = 1.6180 n = 17 v = 1.6180 n = 16 v = 1.6180 n = 15 v = 1.6180 n = 14 v = 1.6180 n = 13 v = 1.6180 n = 12 v = 1.6180 n = 11 v = 1.6180 n = 10 v = 1.6180 n = 9 v = 1.6180 n = 8 v = 1.6180 n = 7 v = 1.6180 n = 6 v = 1.6180 n = 5 v = 1.6180 n = 4 v = 1.6180 n = 3 v = 1.6180 n = 2 v = 1.6180 n = 1 v = 1.6180 n = 0