Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 156672

Submitted on 1 Nov 2012 by James

Correct

19Size
Leading solution size is 11.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
a = [45 15 200 300];
arraygcdok=5;
assert(isequal(arraygcd(a),arraygcdok))
ans =
    45
ans =
    45
ans =
    15
ans =
     5
ans =
     5
2
Pass
 
%%
a = [140 7 14 35 42];
arraygcdok=7;
assert(isequal(arraygcd(a),arraygcdok))
ans =
   140
ans =
   140
ans =
     7
ans =
     7
ans =
     7
ans =
     7
3
Pass
 
%%
a = [100 90 70 2000];
arraygcdok=10;
assert(isequal(arraygcd(a),arraygcdok))
ans =
   100
ans =
   100
ans =
    10
ans =
    10
ans =
    10