Choose Without Order

Combinations answer the question: how many ways can you choose some items when the order does not matter? Given n and k, return C(n, k), the number of ways to choose k items from n. For example, choosing 2 people from 5 can be done in 10 ways.

Примеры

Ввод
5, 2
Вывод
10
Ввод
10, 5
Вывод
252
Ввод
50, 10
Вывод
10272278170

Нужно реализовать

def combination(n: int, k: int) -> int:

Теги

math
PostgreSQLv16

Koodin suorituksen tulos näkyy tässä

Visible tests
1
Input
5, 2
Expected10
2
Input
10, 5
Expected252
3
Input
50, 10
Expected10272278170
4
Input
40, 10
Expected847660528
5
Input
10, 10
Expected1
6
Input
999999, 5
Expected8.333208334041665e+27
Focus radio
Paused · SomaFM · Fluid