Binomial Coefficients C(n, k) — Pascal's Triangle & Modular Queries

Build Pascal's triangle by addition, then answer C(n,k) mod p with a factorial / inverse-factorial table. Step through both.

Pascal DP: O(n²) Precompute: O(N) Query mod p: O(1)
Pascal cells filled: 0
Additions: 0
fact[] / invFact[] size: 0
Modular inverses used: 0

Pascal's Triangle — C(n,k) = C(n−1,k−1) + C(n−1,k)

parent cells new cell (sum) query result

Factorial / Inverse-Factorial Table (mod p)

ifact[i] = i! mod pinvFact[i] = (i!)⁻¹ mod p
C(n,k) mod p = —

What's happening

Press Build Triangle to fill Pascal's triangle row by row, then Query C(n,k) mod p to answer with the factorial formula.

Big-O Reference

MethodSetupPer value / queryModulus
Pascal triangle DPO(n²)O(1) lookupany
Multiplicative formulaO(min(k,n−k))none
Factorials + inverseO(N)O(1)prime, n<p
Inverse-factorial sweepO(N + log p)prime
Lucas (huge n)O(p)O(log_p n)prime, n≥p

Operation Log