Python - Binomial coefficient - 30 seconds of code Skip to content

Home

Binomial coefficient

The binomial coefficient is the number of ways to choose k items from n items without repetition and without order. In Python, you can calculate the binomial coefficient using the math.comb() function.s

from math import comb

def binomial_coefficient(n, k):
  return comb(n, k)

binomial_coefficient(8, 2) # 28

More like this

  • Collection · 8 articles

    Python Math

    Learn how to perform common mathematical operations in Python 3.6 with this article collection.

  • Python ·

    Hamming distance

    Learn how to calculate the Hamming distance between two values.

  • Python ·

    Prime factors of number

    Find the list of prime factors of a number, using a simple Python function.

Start typing a keyphrase to see matching articles.