diff options
author | Yash Aggarwal <Aggarwal.yash2011@gmail.com> | 2019-06-01 07:21:27 (GMT) |
---|---|---|
committer | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-06-01 07:21:27 (GMT) |
commit | 4a686504eb2bbf69adf78077458508a7ba131667 (patch) | |
tree | 1fed04a5328f196e158ee5e22f3cf62044d9756c /Doc | |
parent | 5ac0b988fd5f1428efe35329c531c7b5c74d37f6 (diff) | |
download | cpython-4a686504eb2bbf69adf78077458508a7ba131667.zip cpython-4a686504eb2bbf69adf78077458508a7ba131667.tar.gz cpython-4a686504eb2bbf69adf78077458508a7ba131667.tar.bz2 |
bpo-35431: Implemented math.comb (GH-11414)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/math.rst | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Doc/library/math.rst b/Doc/library/math.rst index b51e96b..5243970 100644 --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -232,6 +232,21 @@ Number-theoretic and representation functions :meth:`x.__trunc__() <object.__trunc__>`. +.. function:: comb(n, k) + + Return the number of ways to choose *k* items from *n* items without repetition + and without order. + + Also called the binomial coefficient. It is mathematically equal to the expression + ``n! / (k! (n - k)!)``. It is equivalent to the coefficient of k-th term in + polynomial expansion of the expression ``(1 + x) ** n``. + + Raises :exc:`TypeError` if the arguments not integers. + Raises :exc:`ValueError` if the arguments are negative or if k > n. + + .. versionadded:: 3.8 + + Note that :func:`frexp` and :func:`modf` have a different call/return pattern than their C equivalents: they take a single argument and return a pair of values, rather than returning their second return value through an 'output |