choose function
Implementation
int choose(int n, int r, {bool useCache = true}) {
if (useCache) {
return chooseCached(n, r);
}
if (n < r) {
return 0;
}
if (r == 0) {
return 1;
}
var denom = range(start: 1, end: r + 1).fold<int>(1, (a, b) => a * b);
var numer =
range(start: n, end: n - r, step: -1).fold<int>(1, (a, b) => a * b);
return numer ~/ denom;
}