Evaluate binomial coefficients
For a start, you can get the length of the corresponding list of combinations:
Output:
This method is efficient, as Raku will not actually compute each element of the list, since it actually uses an iterator with a defined count-only
method. Such method performs computations in a way similar to the following infix operator:
A possible optimization would use a symmetry property of the binomial coefficient:
One drawback of this method is that it returns a Rat, not an Int. So we actually may want to enforce the conversion:
And this is exactly what the count-only
method does.
Last updated