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 228122

Submitted on 8 Apr 2013 by Binbin Qi

Correct

38Size
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))

                    
2
Pass
 
%%
A = 20; B = 10;
y_correct = [5    10    13    15    17];
assert(isequal(fermat(A,B),y_correct))

                    
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))

                    
4
Pass
 
%%
A = 17; B = 33;
y_correct = [5    10    13    15    17    20    25    26    34];
assert(isequal(fermat(A,B),y_correct))