Code Library Of Others/sgtlaugh/Lucas Theorem.cpp
inline int binomial(long long n, long long k){
        if (k > n) return 0;

        int res = 1;
        while (k){
            res = ((long long)res * count(n % MOD, k % MOD)) % MOD;
            n /= MOD, k /= MOD;
        }
        return res;
    }
/// Lucas theorem, calculates binomial(n, k) modulo MOD, MOD must be a prime
Lucas theorem, calculates binomial(n, k) modulo MOD, MOD must be a prime
Lucas theorem calculates binomial ( n k ) modulo MOD MOD must be a prime
inline int binomial(long long n, long long k){
        if (k > n) return 0;
        int res = 1;
        while (k){
            res = ((long long)res * count(n % MOD, k % MOD)) % MOD;
            n /= MOD, k /= MOD;
        }
        return res;
    }
inline int binomial ( long long n , long long k ) { if ( k > n ) return 0 ; int res = 1 ; while ( k ) { res = ( ( long long ) res * count ( n % MOD , k % MOD ) ) % MOD ; n /= MOD , k /= MOD ; } return res ; }
Lucas theorem, calculates binomial(n, k) modulo MOD, MOD must be a prime
Lucas theorem calculates binomial ( n k ) modulo MOD MOD must be a prime