Cody

Problem 42647. Recursion - Fun

Solution 762990

Submitted on 16 Oct 2015 by Jean-Marie Sainthillier
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 = 1; y_correct = 0.5; assert(isequal(rec_fun(x),y_correct))

ans = 0.5000 1.9500 4.7050 9.9395 19.8851 38.7816 74.6850

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

ans = 0.5000 1.9500 4.7050 9.9395 19.8851 38.7816 74.6850

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))

ans = 1.0e+05 * Columns 1 through 9 0 0 0 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))

ans = 0.5000 1.9500 4.7050 9.9395 19.8851 38.7816 74.6850