Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ choose() [1/2]

int stan::math::choose ( int  n,
int  k 
)
inline

Return the binomial coefficient for the specified integer arguments.

The binomial coefficient, \({n \choose k}\), read "n choose k", is defined for \(0 \leq k \leq n\) (otherwise return 0) by

\({n \choose k} = \frac{n!}{k! (n-k)!}\).

Parameters
ntotal number of objects
knumber of objects chosen
Returns
n choose k or 0 iff k > n
Exceptions
std::domain_errorif either argument is negative or the result will not fit in an int type

Definition at line 29 of file choose.hpp.