Files
30-seconds-of-code/snippets/binomial_coefficient.md
Isabelle Viktoria Maciohsek 562ccb547e Add binomial_coefficient
2020-10-04 11:56:31 +03:00

345 B

title, tags
title tags
binomial_coefficient 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.
from math import comb

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