Add binomial_coefficient

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-04 11:56:31 +03:00
parent 26556cf02e
commit 562ccb547e

View File

@ -0,0 +1,19 @@
---
title: binomial_coefficient
tags: math,beginner
---
Return the number of ways to choose `k` items from `n` items without repetition and without order.
- Use `math.comb()` to calculate the binomial coefficient.
```py
from math import comb
def binomial_coefficient(n, k):
return comb(n, k)
```
```py
binomial_coefficient(8, 2) # 28
```