Math Functions
math.comb()
Count unordered selections of k distinct items from n. Negative arguments raise ValueError; k greater than n gives zero.
Formal Syntax & Structure
python syntaxpython
math.comb(n, k, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| n | int | Nonnegative integer input. |
| k | int | Number of items to select, nonnegative. |
Return Value
int
Integer result, exact for integer arithmetic.
Working Example
Example Snippetpython
import mathprint(math.comb(8, 2))