Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

binomial coefficient

facts = {}
def fact(n):
    if n == 1:
        return 1
    elif facts.get(n) is not None:
        return facts[n]
    else:
        facts[n] = n * fact(n-1)
        return facts[n]
    
def binomial_coefficient(n, k):
    if n == 0 or k == 0 or k == n:
        return 1
    a = fact(n)
    b = fact(k)
    c = fact(n-k)
    return a//(b*c) 
 
PREVIOUS NEXT
Tagged: #binomial #coefficient
ADD COMMENT
Topic
Name
7+4 =