Cody

Problem 42647. Recursion - Fun

Solution 869707

Submitted on 10 Apr 2016 by William
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
x = 1; y_correct = 0.5; assert(isequal(rec_fun(x),y_correct))

out = 0.5000

2   Pass
x = 5; y_correct = [0.5000 1.9500 4.7050 9.9395 19.8851]; assert(isequal(rec_fun(x),y_correct))

out = 0.5000 1.9500 4.7050 9.9395 19.8851

3   Pass
x = 20; y_correct = (1.0e+05)*[ 0.0000 0.0000 0.0000 0.0001 0.0002 0.0004 0.0007 0.0014 0.0027 0.0052 0.0099 0.0188 0.0356 0.0677 0.1287 0.2446 0.4647 0.8829 1.6776 3.1874]; assert(isequal(rec_fun(x),y_correct))

out = 1.0e+05 * Columns 1 through 9 0.0000 0.0000 0.0000 0.0001 0.0002 0.0004 0.0007 0.0014 0.0027 Columns 10 through 18 0.0052 0.0099 0.0188 0.0356 0.0677 0.1287 0.2446 0.4647 0.8829 Columns 19 through 20 1.6776 3.1874

4   Pass
x = 7; y_correct = [0.5000 1.9500 4.7050 9.9395 19.8851 38.7816 74.6850]; assert(isequal(rec_fun(x),y_correct))

out = 0.5000 1.9500 4.7050 9.9395 19.8851 38.7816 74.6850

Suggested Problems

More from this Author3

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!