11template <
typename Real>
13 static_assert(std::is_arithmetic_v<Real>);
16 throw std::invalid_argument(
"It must be n >= k >= 0.");
23 Real result = n - k + 1;
24 for (
int i = 1; i < k; ++i) {
25 result *= (n - k + 1 + i) / (i + 1);
31template <
typename Real>
33 static_assert(std::is_arithmetic_v<Real>);
36 throw std::invalid_argument(
"It must be n >= 0.");
43 for (
int i = 2; i <= n; ++i) {
Real binomial_coefficient(Real n, Real k)