def comb_mul
import bend-collections@1.0.0.0/src/math/generic.bend as Genericimport Base
import bend-collections@1.0.0.0/src/math/num.bend as N
481# C(n, i+1) = (r / g) * ((n - i) / ((i + 1) / g)) with r = C(n, i) and
482# g = gcd(r, i + 1): exact, and it overflows only if C(n, i+1) does (C(n, i)
483# grows for i < n / 2)
484def comb_mul(~T: Data, ~op: N.Op<T> -> T, ~test: N.Test<T> -> Bool, +r: T, +t: T, +j: T, +g: T) -> T & Bool:
485 mul_by(~T, ~op, ~test, op(N.Quot{t, op(N.Quot{j, g})}), (op(N.Quot{r, g}), True{}))