logo
pub fn combinations(n: u64, k: u64) -> f64
Expand description

Calculate the number of combinations when choosing k elements from n elements without replacement. This is also known as n over k, or the binomial coefficient. Time complexity: O(min(k, n - k))

Examples

use approx::assert_relative_eq;
use bio::stats::combinatorics::combinations;
assert_relative_eq!(combinations(5, 3), 10., epsilon = f64::EPSILON);