fork download
  1. import java.math.BigInteger;
  2.  
  3. class Main
  4. {
  5. public static void main (String[] args)
  6. {
  7. System.out.println( binomial(4,2) );
  8. System.out.println( binomial(133,71) );
  9. }
  10.  
  11. static BigInteger binomial(int N, int K) {
  12. for (int k = 0; k < K; k++) {
  13. ret = ret.multiply(BigInteger.valueOf(N-k))
  14. .divide(BigInteger.valueOf(k+1));
  15. }
  16. return ret;
  17. }
  18. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
6
555687036928510235891585199545206017600