Cody

Problem 84. Longest Divisor Run

Solution 2677418

Submitted on 10 Jul 2020 by David K
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 = [93 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 961 1073 205] len_correct = 5; d_correct = 43; [len,d] = divisor_run(a); assert(isequal(len,len_correct) && isequal(d,d_correct))

a = Columns 1 through 15 93 1147 473 259 629 1591 851 533 2021 86 817 2279 1763 961 1073 Column 16 205 divisorRun = 3 1 31 2 37 1 11 1 43 1 7 1 17 1 43 1 37 4 23 1 13 1 41 1 47 1 2 1 19 1 53 1 43 5 41 1 31 1 29 1 37 1 5 1 41 1 len = 5 ind = 17 d = 43

2   Pass
a = [166 553 1241 869 237 395 1079 1577]; len_correct = 3; d_correct = 79; [len,d] = divisor_run(a); assert(isequal(len,len_correct) && isequal(d,d_correct))

divisorRun = 2 1 83 1 7 1 79 1 17 1 73 1 11 1 3 1 79 3 5 1 13 1 83 2 19 1 len = 3 ind = 9 d = 79

3   Pass
a = [533 205 123 287 451 697 82]; len_correct = 7; d_correct = 41; [len,d] = divisor_run(a); assert(isequal(len,len_correct) && isequal(d,d_correct))

divisorRun = 13 1 5 1 3 1 7 1 11 1 17 1 41 7 2 1 len = 7 ind = 7 d = 41

4   Pass
a = [3937 7493 1397 5633 6439 3151 5617 685 7261 5069 ... 959 3973 411 2603 2329 1781 262]; len_correct = 12; d_correct = 137; [len,d] = divisor_run(a); assert(isequal(len,len_correct) && isequal(d,d_correct))

divisorRun = 31 1 59 1 127 3 11 1 43 1 131 1 47 1 23 1 41 1 5 1 53 1 37 1 7 1 29 1 3 1 19 1 17 1 137 12 13 1 2 1 131 1 len = 12 ind = 18 d = 137

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!