how to find ncr mod p code example
Example: ncr mod p
ll nCrModp(ll n, ll r)
{
if (r > n - r)
r = n - r;
ll C[r + 1];
memset(C, 0, sizeof(C));
C[0] = 1;
for (ll i = 1; i <= n; i++) {
for (ll j = min(i, r); j > 0; j--)
C[j] = (C[j] + C[j - 1]) % mod;
}
return C[r];
}