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

Incorrect

86Size
Leading solution size is 44.
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
 
%%
tic
N=5;K=2;
NK=nchoosekJava(N,K);
toc
assert(strcmp(NK,num2str(nchoosek(N,K))))
Elapsed time is 0.030594 seconds.
2
Fail
 
%%
tic
N=randi(10);
K=randi(N);
NK=nchoosekJava(N,K);
toc
assert(strcmp(NK,num2str(nchoosek(N,K))))
Error: Assertion failed.
3
Pass
 
%%
tic
N=100;
K=50;
NK=nchoosekJava(N,K);
toc
assert(strcmp(NK,'100891344545564193334812497256'))
Elapsed time is 0.018829 seconds.
4
Pass
 
%%
tic
N=200;
K=75;
NK=nchoosekJava(N,K);
toc
assert(strcmp(NK,'168849997346404286704489530268603459022868706883102845056'))
Elapsed time is 0.028852 seconds.