summaryrefslogtreecommitdiff
path: root/math/binomial.cpp
blob: 61d9d69d90f0038b6043b64318f14884c33efaf7 (plain)
1
2
3
4
5
6
7
8
9
10
ll calc_binom(ll N, ll K) {
   ll r = 1, d;
   if (K > N) return 0;
   for (d = 1; d <= K; d++) {
      r *= N--;
      r /= d;
   }
   return r;
}