Here is the implementation of C(m,n) without overflowing the answer.
int gcd(int a, int b) {
while(b) {
int c = a%b;
a = b;
b = c;
}
return a;
}
int C(int m, int n) {
if(m - n < n) {
n = m - n;
}
int result = 1;
for(int i = 1; i <= n; i++) {
int mult = m;
int divi = i;
int g = gcd(mult,divi);
mult /= g;
divi /= g;
result /= divi;
result *= mult;
m--;
}
return result;
}