Files
30-seconds-of-code/snippets/binomial_coefficient.md
Isabelle Viktoria Maciohsek a2cd6db3b0 Update snippet descriptions
2020-11-02 19:27:07 +02:00

20 lines
349 B
Markdown

---
title: binomial_coefficient
tags: math,beginner
---
Calculates 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
```