Using Euler 's theorem of Modular  multiplicative inverse to find  the inverse of a number.  (1/a)%mod=a^(m?2)%mod
inv_ifact = binExp ( ifact , mod - 2 ) NEW_LINE inv_dfact = binExp ( dfact , mod - 2 ) NEW_LINE denm = ( ( ( inv_ifact % mod ) * ( inv_dfact % mod ) ) % mod ) NEW_LINE answer = ( ( ( nfact % mod ) * ( denm % mod ) ) % mod ) NEW_LINE return answer NEW_LINE