Cody

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

Solution 3105171

Submitted on 7 Oct 2020 by ivan fernandez
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))

a = 1 v = 1 a = 3 v = 1 3 a = 7 v = 1 3 7 a = 15 v = 1 3 7 15 a = 31 v = 1 3 7 15 31 y = 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))

a = 1 v = 1 a = 3 v = 1 3 a = 7 v = 1 3 7 a = 15 v = 1 3 7 15 a = 31 v = 1 3 7 15 31 a = 63 v = 1 3 7 15 31 63 a = 127 v = 1 3 7 15 31 63 127 a = 255 v = 1 3 7 15 31 63 127 255 a = 511 v = 1 3 7 15 31 63 127 255 511 a = 1023 v = 1 3 7 15 31 63 127 255 511 1023 a = 2047 v = 1 3 7 15 31 63 127 255 511 1023 2047 y = 1 3 7 15 31 63 127 255 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))

a = 2 v = 2 a = 5 v = 2 5 a = 11 v = 2 5 11 a = 23 v = 2 5 11 23 a = 47 v = 2 5 11 23 47 a = 95 v = 2 5 11 23 47 95 a = 191 v = 2 5 11 23 47 95 191 a = 383 v = 2 5 11 23 47 95 191 383 a = 767 v = 2 5 11 23 47 95 191 383 767 a = 1535 v = 2 5 11 23 47 95 191 383 767 1535 a = 3071 v = 2 5 11 23 47 95 191 383 767 1535 3071 y = 2 5 11 23 47 95 191 383 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))

a = 3 v = 3 a = 7 v = 3 7 a = 15 v = 3 7 15 a = 31 v = 3 7 15 31 a = 63 v = 3 7 15 31 63 a = 127 v = 3 7 15 31 63 127 a = 255 v = 3 7 15 31 63 127 255 a = 511 v = 3 7 15 31 63 127 255 511 a = 1023 v = 3 7 15 31 63 127 255 511 1023 a = 2047 v = 3 7 15 31 63 127 255 511 1023 2047 a = 4095 v = 3 7 15 31 63 127 255 511 1023 2047 4095 y = 3 7 15 31 63 127 255 511 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))

a = 5 v = 5 a = 11 v = 5 11 a = 23 v = 5 11 23 a = 47 v = 5 11 23 47 a = 95 v = 5 11 23 47 95 a = 191 v = 5 11 23 47 95 191 a = 383 v = 5 11 23 47 95 191 383 a = 767 v = 5 11 23 47 95 191 383 767 a = 1535 v = 5 11 23 47 95 191 383 767 1535 a = 3071 v = 5 11 23 47 95 191 383 767 1535 3071 a = 6143 v = 5 11 23 47 95 191 383 767 1535 3071 6143 y = 5 11 23 47 95 191 383 767 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))

a = 7 v = 7 a = 15 v = 7 15 a = 31 v = 7 15 31 a = 63 v = 7 15 31 63 a = 127 v = 7 15 31 63 127 a = 255 v = 7 15 31 63 127 255 a = 511 v = 7 15 31 63 127 255 511 a = 1023 v = 7 15 31 63 127 255 511 1023 a = 2047 v = 7 15 31 63 127 255 511 1023 2047 y = 7 15 31 63 127 255 511 1023 2047

Community Treasure Hunt

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

Start Hunting!