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 291229

Submitted on 28 Jul 2013 by Alfonso Nieto-Castanon

Correct

31Size
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
 
%%
X = 2;
M = 1;
Y = 5;
y_correct = 3;
assert(isequal(inverse_modulus(X,M,Y),y_correct))

                    
2
Pass
 
%%
X = 5;
M = 1;
Y = 6;
y_correct = 5;
assert(isequal(inverse_modulus(X,M,Y),y_correct))

                    
3
Pass
 
%%
X = 2;
M = 1;
Y = 7;
y_correct = 4;
assert(isequal(inverse_modulus(X,M,Y),y_correct))

                    
4
Pass
 
%%
X = [2 5 2];
M = [1 1 1];
Y = [5 6 7];
y_correct = [3 5 4];
assert(isequal(inverse_modulus(X,M,Y),y_correct))

                    
5
Pass
 
%% this example is from wikipedia
X = 3;
M = 1;
Y = 11;
y_correct = 4;
assert(isequal(inverse_modulus(X,M,Y),y_correct))

                    
6
Pass
 
%%
X = 3;
M = 2;
Y = 11;
y_correct = 8;
assert(isequal(inverse_modulus(X,M,Y),y_correct))

                    
7
Pass
 
%%
X = [3 5 7];
M = [1 2 3];
Y = [5 6 13];
y_correct = [2 4 6];
assert(isequal(inverse_modulus(X,M,Y),y_correct))