Cody

Solution 1911479

Submitted on 25 Aug 2019 by Tetsuji Tsuda
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))

a = [] a = 1 v = 1 c = 1

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

a = [] a = 2 v = 2 v = 1 a = 2 1 v = 1 c = 2 1

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

a = [] a = 5 v = 5 ans = logical 1 v = 16 a = 5 16 v = 16 v = 8 a = 5 16 8 v = 8 v = 4 a = 5 16 8 4 v = 4 v = 2 a = 5 16 8 4 2 v = 2 v = 1 a = 5 16 8 4 2 1 v = 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))

a = [] a = 22 v = 22 v = 11 a = 22 11 v = 11 ans = logical 1 v = 34 a = 22 11 34 v = 34 v = 17 a = 22 11 34 17 v = 17 ans = logical 1 v = 52 a = 22 11 34 17 52 v = 52 v = 26 a = 22 11 34 17 52 26 v = 26 v = 13 a = 22 11 34 17 52 26 13 v = 13 ans = logical 1 v = 40 a = 22 11 34 17 52 26 13 40 v = 40 v = 20 a = 22 11 34 17 52 26 13 40 20 v = 20 v = 10 a = 22 11 34 17 52 26 13 40 20 10 v = 10 v = 5 a = 22 11 34 17 52 26 13 40 20 10 5 v = 5 ans = logical 1 v = 16 a = 22 11 34 17 52 26 13 40 20 10 5 16 v = 16 v = 8 a = 22 11 34 17 52 26 13 40 20 10 5 16 8 v = 8 v = 4 a = 22 11 34 17 52 26 13 40 20 10 5 16 8 4 v = 4 v = 2 a = 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 v = 2 v = 1 a = 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 v = 1 c = 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1