n choose k Complexity: O(min(k, n - k))
import mir.bignum.fp: Fp; import mir.math.common: approxEqual; static assert(is(typeof(binomialCoefficient(30, 18)) == Fp!128), typeof(binomialCoefficient(30, 18)).stringof); static assert(cast(double) binomialCoefficient(30, 18) == 86493225); assert(approxEqual(cast(double) binomialCoefficient(100, 40), 1.374623414580281150126736972e+28));
Quickly computes binomial coefficient using extended precision floating point type mir.bignum.fp.