Binomial coefficient

Python, Math · Nov 2, 2020

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

More like this

  • Greatest common divisor

    Calculates the greatest common divisor of a list of numbers.

    Python, Math · Sep 15, 2020

  • Average

    Calculates the average of two or more numbers.

    Python, Math · Nov 2, 2020

  • Factorial

    Calculates the factorial of a number.

    Python, Math · Sep 15, 2020