Cody

Solution 2065597

Submitted on 20 Dec 2019 by Alistair James
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
n = 1; c_correct = 1; assert(isequal(collatz(n),c_correct))

value = 1 array = 1 c = 1

2   Pass
n = 2; c_correct = [2 1]; assert(isequal(collatz(n),c_correct))

value = 2 array = 2 value = 1 array = 2 1 value = 1 c = 2 1

3   Pass
n = 5; c_correct = [5 16 8 4 2 1]; assert(isequal(collatz(n),c_correct))

value = 5 array = 5 value = 16 array = 5 16 value = 16 value = 8 array = 5 16 8 value = 8 value = 4 array = 5 16 8 4 value = 4 value = 2 array = 5 16 8 4 2 value = 2 value = 1 array = 5 16 8 4 2 1 value = 1 c = 5 16 8 4 2 1

4   Pass
n = 22; c_correct = [22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1]; assert(isequal(collatz(n),c_correct))

value = 22 array = 22 value = 11 array = 22 11 value = 11 value = 34 array = 22 11 34 value = 34 value = 17 array = 22 11 34 17 value = 17 value = 52 array = 22 11 34 17 52 value = 52 value = 26 array = 22 11 34 17 52 26 value = 26 value = 13 array = 22 11 34 17 52 26 13 value = 13 value = 40 array = 22 11 34 17 52 26 13 40 value = 40 value = 20 array = 22 11 34 17 52 26 13 40 20 value = 20 value = 10 array = 22 11 34 17 52 26 13 40 20 10 value = 10 value = 5 array = 22 11 34 17 52 26 13 40 20 10 5 value = 5 value = 16 array = 22 11 34 17 52 26 13 40 20 10 5 16 value = 16 value = 8 array = 22 11 34 17 52 26 13 40 20 10 5 16 8 value = 8 value = 4 array = 22 11 34 17 52 26 13 40 20 10 5 16 8 4 value = 4 value = 2 array = 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 value = 2 value = 1 array = 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 value = 1 c = 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1