Cody

# Problem 44448. Project Euler: Problem 14 Longest Collatz sequence

Solution 1778868

Submitted on 9 Apr 2019
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
filetext = fileread('euler014.m'); assert(isempty(strfind(filetext, 'tic')),'tic forbidden'); assert(isempty(strfind(filetext, 'toc')),'toc forbidden'); assert(isempty(strfind(filetext, 'pause')),'pause forbidden');

2   Fail
N = 1234321; num_correct = 1117065; len_correct = 528; [num, len] = euler014(N); assert(isequal(num, num_correct)); assert(isequal(len, len_correct));

Undefined function or variable 't'. Error in euler014 (line 15) t(ii) = count + t(b); Error in Test2 (line 4) [num, len] = euler014(N);

3   Fail
N = 10; num_correct = 9; len_correct = 20; [num, len] = euler014(N); assert(isequal(num, num_correct)); assert(isequal(len, len_correct));

Undefined function or variable 't'. Error in euler014 (line 15) t(ii) = count + t(b); Error in Test3 (line 4) [num, len] = euler014(N);

4   Fail
N = 100; num_correct = 97; len_correct = 119; [num, len] = euler014(N); assert(isequal(num, num_correct)); assert(isequal(len, len_correct));

Undefined function or variable 't'. Error in euler014 (line 15) t(ii) = count + t(b); Error in Test4 (line 4) [num, len] = euler014(N);

5   Fail
N = 1000; num_correct = 871; len_correct = 179; [num, len] = euler014(N); assert(isequal(num, num_correct)); assert(isequal(len, len_correct));

Undefined function or variable 't'. Error in euler014 (line 15) t(ii) = count + t(b); Error in Test5 (line 4) [num, len] = euler014(N);

6   Fail
N = 1e4; num_correct = 6171; len_correct = 262; [num, len] = euler014(N); assert(isequal(num, num_correct)); assert(isequal(len, len_correct));

Undefined function or variable 't'. Error in euler014 (line 15) t(ii) = count + t(b); Error in Test6 (line 4) [num, len] = euler014(N);

7   Fail
N = 1e5; num_correct = 77031; len_correct = 351; [num, len] = euler014(N); assert(isequal(num, num_correct)); assert(isequal(len, len_correct));

Undefined function or variable 't'. Error in euler014 (line 15) t(ii) = count + t(b); Error in Test7 (line 4) [num, len] = euler014(N);

8   Fail
N = 1e6; num_correct = 837799; len_correct = 525; [num, len] = euler014(N); assert(isequal(num, num_correct)); assert(isequal(len, len_correct));

Undefined function or variable 't'. Error in euler014 (line 15) t(ii) = count + t(b); Error in Test8 (line 4) [num, len] = euler014(N);

9   Fail
N = 1e7; num_correct = 8400511; len_correct = 686; tic; [num, len] = euler014(N); t = toc; t assert(isequal(num, num_correct)); assert(isequal(len, len_correct)); assert(t < 1.5); assert(t > 0.001);

Undefined function or variable 't'. Error in euler014 (line 15) t(ii) = count + t(b); Error in Test9 (line 5) [num, len] = euler014(N);

10   Fail
N = 1e8; num_correct = 63728127; len_correct = 950; tic; [num, len] = euler014(N); t = toc; t assert(isequal(num, num_correct)); assert(isequal(len, len_correct)); assert(t < 15); assert(t > 1);

Undefined function or variable 't'. Error in euler014 (line 15) t(ii) = count + t(b); Error in Test10 (line 5) [num, len] = euler014(N);

11   Fail
N = randi([7e7, 1e8]); num_correct = 63728127; len_correct = 950; tic; [num, len] = euler014(N); t = toc; t assert(isequal(num, num_correct)); assert(isequal(len, len_correct)); assert(t < 15); assert(t > 1);

Undefined function or variable 't'. Error in euler014 (line 15) t(ii) = count + t(b); Error in Test11 (line 5) [num, len] = euler014(N);