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

NameTypeDescription
nintNonnegative integer input.
kintNumber of items to select, nonnegative.

Return Value

int

Integer result, exact for integer arithmetic.

Working Example

Example Snippetpython
import mathprint(math.comb(8, 2))
Python Reference