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 266829

Submitted on 25 Jun 2013 by andrea84

Correct

56Size
Leading solution size is 31.
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 = 4; B = 10;
y_correct = 5;
assert(isequal(fermat(A,B),y_correct))
v =
     5
v =
     5     5
ans =
     5
2
Pass
 
%%
A = 20; B = 10;
y_correct = [5    10    13    15    17];
assert(isequal(fermat(A,B),y_correct))
v =
     5
v =
     5     5
v =
     5     5    10
v =
     5     5    10    10
v =
     5     5    10    10    13
v =
     5     5    10    10    13    15
v =
     5     5    10    10    13    15    17
ans =
     5    10    13    15    17
3
Pass
 
%%
A = 20; B = 30;
y_correct = [ 5    10    13    15    17    20    25    26    29    30    34];
assert(isequal(fermat(A,B),y_correct))
v =
     5
v =
     5     5
v =
     5     5    13
v =
     5     5    13    10
v =
     5     5    13    10    25
v =
     5     5    13    10    25    10
v =
     5     5    13    10    25    10    17
v =
     5     5    13    10    25    10    17    15
v =
     5     5    13    10    25    10    17    15    26
v =
     5     5    13    10    25    10    17    15    26    13
v =
     5     5    13    10    25    10    17    15    26    13    15
v =
     5     5    13    10    25    10    17    15    26    13    15    20
v =
     5     5    13    10    25    10    17    15    26    13    15    20    17
v =
     5     5    13    10    25    10    17    15    26    13    15    20    17    25
v =
     5     5    13    10    25    10    17    15    26    13    15    20    17    25    20
v =
     5     5    13    10    25    10    17    15    26    13    15    20    17    25    20    34
v =
  Columns 1 through 16
     5     5    13    10    25    10    17    15    26    13    15    20    17    25    20    34
  Column 17
    30
v =
  Columns 1 through 16
     5     5    13    10    25    10    17    15    26    13    15    20    17    25    20    34
  Columns 17 through 18
    30    25
v =
  Columns 1 through 16
     5     5    13    10    25    10    17    15    26    13    15    20    17    25    20    34
  Columns 17 through 19
    30    25    29
ans =
     5    10    13    15    17    20    25    26    29    30    34
4
Pass
 
%%
A = 17; B = 33;
y_correct = [5    10    13    15    17    20    25    26    34];
assert(isequal(fermat(A,B),y_correct))
v =
     5
v =
     5     5
v =
     5     5    13
v =
     5     5    13    10
v =
     5     5    13    10    25
v =
     5     5    13    10    25    10
v =
     5     5    13    10    25    10    17
v =
     5     5    13    10    25    10    17    15
v =
     5     5    13    10    25    10    17    15    26
v =
     5     5    13    10    25    10    17    15    26    13
v =
     5     5    13    10    25    10    17    15    26    13    15
v =
     5     5    13    10    25    10    17    15    26    13    15    20
v =
     5     5    13    10    25    10    17    15    26    13    15    20    17
v =
     5     5    13    10    25    10    17    15    26    13    15    20    17    25
v =
     5     5    13    10    25    10    17    15    26    13    15    20    17    25    20
v =
     5     5    13    10    25    10    17    15    26    13    15    20    17    25    20    34
ans =
     5    10    13    15    17    20    25    26    34