Cody

Problem 1855. Usage of java.math : N Choose K with unlimited precision

Solution 430559

Submitted on 11 Apr 2014 by J.R.! Menzinger
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
%% tic N=5;K=2; NK=nchoosekJava(N,K); toc assert(strcmp(NK,num2str(nchoosek(N,K))))

ans = 1 ans = 1 ans = 1 ans = 10 Elapsed time is 0.029346 seconds.

2   Pass
%% tic N=randi(10); K=randi(N); NK=nchoosekJava(N,K); toc assert(strcmp(NK,num2str(nchoosek(N,K))))

ans = 1 ans = 1 ans = 1 ans = 8 Elapsed time is 0.003175 seconds.

3   Pass
%% tic N=100; K=50; NK=nchoosekJava(N,K); toc assert(strcmp(NK,'100891344545564193334812497256'))

ans = 1 ans = 1 ans = 1 ans = 100891344545564193334812497256 Elapsed time is 0.028107 seconds.

4   Pass
%% tic N=200; K=75; NK=nchoosekJava(N,K); toc assert(strcmp(NK,'168849997346404286704489530268603459022868706883102845056'))

ans = 1 ans = 1 ans = 1 ans = 168849997346404286704489530268603459022868706883102845056 Elapsed time is 0.053028 seconds.

Suggested Problems

More from this Author241

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!