|
NTLib - Number Theory Library 0.9
|
Compute binomial coefficients. More...
Functions | |
| template<Integer T> | |
| constexpr T | ntlib::binom (T n, T k) noexcept |
| Computes a single binomial coefficient. | |
| template<Integer T> | |
| constexpr T | ntlib::mod_p_binom (T n, T k, T p) noexcept |
| Compute a single binomial coefficient module a sufficiently large prime. | |
| template<Integer T> | |
| constexpr T | ntlib::mod_pp_binom (T n, T k, T p, T e) |
| Computes a single binomial coefficient modulo a prime power. | |
| template<Integer T> | |
| constexpr T | ntlib::mod_binom (T n, T k, T m) |
| Computes a single binomial coefficient modulo an arbitrary number. | |
| template<Integer T> | |
| constexpr std::vector< std::vector< T > > | ntlib::binom_table (T N) |
| Computes the first \(N\) rows of Pascal's triangle. | |
| template<Integer T> | |
| constexpr std::vector< std::vector< T > > | ntlib::mod_binom_table (std::size_t N, T m) |
| Computes the first \(N\) rows of Pascal's triangle module some number \(m\). | |
Compute binomial coefficients.
Compute the binomial coefficient \({n \choose k}\) for \(0 \leq k \leq n\), possibly modulo some number \(m\). The binomial coeffient counts the number of \(k\)-element subsets of an \(n\)-element universe.
Code for one-shot computation modulo a number \(m\) is based on https://cp-algorithms.com/combinatorics/binomial-coefficients.html.
Files | |
| file | modules/combinatorics/binomial_coefficient.cpp |
| Primary module interface unit for module binomial_coefficient. | |