Cody

Solution 1240445

Submitted on 27 Jul 2017 by Augusto Mazzei
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 = [45 15 200 300]; arraygcdok=5; assert(isequal(arraygcd(a),arraygcdok))

ans = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ans = 1 1 0 0 0 0 2 0 1 3 0 0 0 0 0 0 3 3 2 0 3 1 4 6 5 7 0 4 0 6 2 3 5 5 0 0 1 4 2 3 9 3 8 0 6 2 5 1 3 1 4 6 0 0 5 0 ans = 5

2   Pass
a = [140 7 14 35 42]; arraygcdok=7; assert(isequal(arraygcd(a),arraygcdok))

ans = 2 3 4 5 6 7 ans = 0 1 0 1 0 2 1 2 2 0 0 3 2 3 2 0 2 4 0 2 2 1 2 5 0 0 0 0 0 0 ans = 7

3   Pass
a = [100 90 70 2000]; arraygcdok=10; assert(isequal(arraygcd(a),arraygcdok))

ans = 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 ans = 0 0 0 0 1 0 1 2 0 2 2 0 0 0 0 0 4 0 4 2 2 6 0 5 4 2 6 0 1 0 7 2 0 0 0 0 1 2 4 9 4 6 10 8 9 12 5 11 2 6 0 12 10 0 10 5 4 10 6 0 15 5 2 11 10 0 16 2 5 14 13 5 0 10 10 0 16 6 7 5 12 2 4 20 8 21 1 22 4 18 22 8 0 15 20 0 22 12 18 24 19 9 16 2 16 6 14 12 13 3 12 28 10 0 10 20 7 28 8 16 4 26 6 16 1 24 4 20 32 22 2 28 30 20 0 5 28 18 34 20 26 16 33 2 24 14 32 24 22 12 31 11 20 10 30 0 18 8 29 32 16 6 28 26 14 4 27 22 12 2 26 20 10 0 25 20 8 44 24 22 6 43 23 26 4 42 22 32 2 41 21 40 0 40 20 0 49 39 19 11 48 38 18 24 47 37 17 39 46 36 16 2 45 35 15 20 44 34 14 40 43 33 13 5 42 32 12 28 41 31 11 53 40 30 10 20 39 29 9 48 38 28 8 16 37 27 7 47 36 26 6 16 35 25 5 50 34 24 4 20 33 23 3 57 32 22 2 28 31 21 1 68 30 20 0 40 ans = 10