Skip to content

Implement geralized binomial coefficients #140991

@rmathar

Description

@rmathar

Feature or enhancement

Proposal:

The Lib/fractions.py is missing the binomial function:

def binomial(n: fractions.Fraction, m :int) :
    """Computs n choose m.

    returns n(n-1)(n-2)...(n-m+1) / (1*2*3*...m)
    """
    val = fractions.Fraction(1)
    for i in range(1,m+1):
        val *= n+1-i
        val /= i
    return val 

Note that this is not the same as the implementation in the math module: here we want to compute the generalized binomial coefficients which allow numerators to be fractions!

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions