Files
30-seconds-of-code/python/s/binomial-coefficient.md
Angelos Chalaris 5c913d20bd Reorganize snippets
2023-05-03 21:19:02 +03:00

436 B

title, type, language, tags, cover, dateModified
title type language tags cover dateModified
Binomial coefficient snippet python
math
digital-nomad-5 2020-11-02T19:27:07+02:00

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.
from math import comb

def binomial_coefficient(n, k):
  return comb(n, k)
binomial_coefficient(8, 2) # 28