Cody

Problem 42673. Longest Collatz Sequence

Solution 3235523

Submitted on 16 Oct 2020
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   Fail
x = 10; assert(isequal(euler14(x),9))

Unrecognized function or variable 'n'. Error in euler14 (line 7) y = 1+euler14(3*n+1); Error in euler14 (line 5) y = 1+euler14(x/2); Error in Test1 (line 2) assert(isequal(euler14(x),9))

2   Fail
x = 100; assert(isequal(euler14(x),97))

Unrecognized function or variable 'n'. Error in euler14 (line 7) y = 1+euler14(3*n+1); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in Test2 (line 2) assert(isequal(euler14(x),97))

3   Fail
x = 96; assert(isequal(euler14(x),73))

Unrecognized function or variable 'n'. Error in euler14 (line 7) y = 1+euler14(3*n+1); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in Test3 (line 2) assert(isequal(euler14(x),73))

4   Fail
x = 1000; assert(isequal(euler14(x),871))

Unrecognized function or variable 'n'. Error in euler14 (line 7) y = 1+euler14(3*n+1); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in Test4 (line 2) assert(isequal(euler14(x),871))

5   Fail
x = 870; assert(isequal(euler14(x),703))

Unrecognized function or variable 'n'. Error in euler14 (line 7) y = 1+euler14(3*n+1); Error in euler14 (line 5) y = 1+euler14(x/2); Error in Test5 (line 2) assert(isequal(euler14(x),703))

6   Fail
assert(isequal(euler14(871),871))

Unrecognized function or variable 'n'. Error in euler14 (line 7) y = 1+euler14(3*n+1); Error in Test6 (line 1) assert(isequal(euler14(871),871))

7   Fail
x = 77030; assert(isequal(euler14(x),52527))

Unrecognized function or variable 'n'. Error in euler14 (line 7) y = 1+euler14(3*n+1); Error in euler14 (line 5) y = 1+euler14(x/2); Error in Test7 (line 2) assert(isequal(euler14(x),52527))

8   Fail
x = 77031; assert(isequal(euler14(x),77031))

Unrecognized function or variable 'n'. Error in euler14 (line 7) y = 1+euler14(3*n+1); Error in Test8 (line 2) assert(isequal(euler14(x),77031))

9   Fail
assert(isequal(euler14(500000),410011))

Unrecognized function or variable 'n'. Error in euler14 (line 7) y = 1+euler14(3*n+1); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in Test9 (line 1) assert(isequal(euler14(500000),410011))

10   Fail
z = 900000; y_correct=837799; assert(isequal(euler14(z),y_correct))

Unrecognized function or variable 'n'. Error in euler14 (line 7) y = 1+euler14(3*n+1); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in euler14 (line 5) y = 1+euler14(x/2); Error in Test10 (line 3) assert(isequal(euler14(z),y_correct))

Suggested Problems

More from this Author43

Community Treasure Hunt

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

Start Hunting!