Cody

# Problem 888. Create a vector whose elements depend on the previous element

Solution 1111910

Submitted on 28 Jan 2017 by paolo77
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
A = 1; iterations = 4; y_correct = [1 3 7 15 31]; assert(isequal(your_fcn_name(A,iterations),y_correct))

B = 1 3 0 0 B = 1 3 7 0 B = 1 3 7 15 B = 1 3 7 15 31

2   Pass
A = 1; iterations = 10; y_correct = [1 3 7 15 31 63 127 255 511 1023 2047]; assert(isequal(your_fcn_name(A,iterations),y_correct))

B = 1 3 0 0 0 0 0 0 0 0 B = 1 3 7 0 0 0 0 0 0 0 B = 1 3 7 15 0 0 0 0 0 0 B = 1 3 7 15 31 0 0 0 0 0 B = 1 3 7 15 31 63 0 0 0 0 B = 1 3 7 15 31 63 127 0 0 0 B = 1 3 7 15 31 63 127 255 0 0 B = 1 3 7 15 31 63 127 255 511 0 B = Columns 1 through 8 1 3 7 15 31 63 127 255 Columns 9 through 10 511 1023 B = Columns 1 through 8 1 3 7 15 31 63 127 255 Columns 9 through 11 511 1023 2047

3   Pass
A = 2; iterations = 10; y_correct = [2 5 11 23 47 95 191 383 767 1535 3071]; assert(isequal(your_fcn_name(A,iterations),y_correct))

B = 2 5 0 0 0 0 0 0 0 0 B = 2 5 11 0 0 0 0 0 0 0 B = 2 5 11 23 0 0 0 0 0 0 B = 2 5 11 23 47 0 0 0 0 0 B = 2 5 11 23 47 95 0 0 0 0 B = 2 5 11 23 47 95 191 0 0 0 B = 2 5 11 23 47 95 191 383 0 0 B = 2 5 11 23 47 95 191 383 767 0 B = Columns 1 through 8 2 5 11 23 47 95 191 383 Columns 9 through 10 767 1535 B = Columns 1 through 8 2 5 11 23 47 95 191 383 Columns 9 through 11 767 1535 3071

4   Pass
A = 3; iterations = 10; y_correct = [3 7 15 31 63 127 255 511 1023 2047 4095]; assert(isequal(your_fcn_name(A,iterations),y_correct))

B = 3 7 0 0 0 0 0 0 0 0 B = 3 7 15 0 0 0 0 0 0 0 B = 3 7 15 31 0 0 0 0 0 0 B = 3 7 15 31 63 0 0 0 0 0 B = 3 7 15 31 63 127 0 0 0 0 B = 3 7 15 31 63 127 255 0 0 0 B = 3 7 15 31 63 127 255 511 0 0 B = Columns 1 through 8 3 7 15 31 63 127 255 511 Columns 9 through 10 1023 0 B = Columns 1 through 8 3 7 15 31 63 127 255 511 Columns 9 through 10 1023 2047 B = Columns 1 through 8 3 7 15 31 63 127 255 511 Columns 9 through 11 1023 2047 4095

5   Pass
A = 5; iterations = 10; y_correct = [5 11 23 47 95 191 383 767 1535 3071 6143]; assert(isequal(your_fcn_name(A,iterations),y_correct))

B = 5 11 0 0 0 0 0 0 0 0 B = 5 11 23 0 0 0 0 0 0 0 B = 5 11 23 47 0 0 0 0 0 0 B = 5 11 23 47 95 0 0 0 0 0 B = 5 11 23 47 95 191 0 0 0 0 B = 5 11 23 47 95 191 383 0 0 0 B = 5 11 23 47 95 191 383 767 0 0 B = Columns 1 through 8 5 11 23 47 95 191 383 767 Columns 9 through 10 1535 0 B = Columns 1 through 8 5 11 23 47 95 191 383 767 Columns 9 through 10 1535 3071 B = Columns 1 through 8 5 11 23 47 95 191 383 767 Columns 9 through 11 1535 3071 6143

6   Pass
A = 7; iterations = 8; y_correct = [7 15 31 63 127 255 511 1023 2047]; assert(isequal(your_fcn_name(A,iterations),y_correct))

B = 7 15 0 0 0 0 0 0 B = 7 15 31 0 0 0 0 0 B = 7 15 31 63 0 0 0 0 B = 7 15 31 63 127 0 0 0 B = 7 15 31 63 127 255 0 0 B = 7 15 31 63 127 255 511 0 B = 7 15 31 63 127 255 511 1023 B = Columns 1 through 8 7 15 31 63 127 255 511 1023 Column 9 2047