Cody

Solution 549317

Submitted on 23 Dec 2014 by James
  • Size: 23
  • This is the leading solution.
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
%% assert(isequal(mod_exp(1000,1000,3),1))

2   Pass
%% assert(isequal(mod_exp(1444,2113,104),40))

3   Pass
%% assert(isequal(mod_exp(1043,313,23),16))

4   Pass
%% assert(isequal(mod_exp(1111,1111,111),1))

5   Pass
%% assert(isequal(mod_exp(1531,9898,123),73))

6   Pass
%% assert(isequal(mod_exp(1323,7878,12),9))

7   Pass
%% assert(isequal(mod_exp(4545,1234,786),429))

8   Pass
%% a = [151:160]; b = [311:320]; c = [41:50]; r = [35 22 38 0 35 16 8 16 40 0]; id = randperm(10); a = a(id); b = b(id); c = c(id); r = r(id); for i = 1:10 assert(isequal(mod_exp(a(i),b(i),c(i)),r(i))) end