Add binomial to math
This commit is contained in:
		| @@ -49,6 +49,14 @@ pub fn factorial(n: u64) -> u64 { | |||||||
|     result |     result | ||||||
| } | } | ||||||
|  |  | ||||||
|  | pub fn binomial(n: u64, k: u64) -> u64 { | ||||||
|  |     if k > n { | ||||||
|  |         0 | ||||||
|  |     } else { | ||||||
|  |         factorial(n) / (factorial(k) * factorial(n - k)) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| pub fn get_divisors(n: u64) -> Vec<u64> { | pub fn get_divisors(n: u64) -> Vec<u64> { | ||||||
|     let mut divisors = HashSet::from([1]); |     let mut divisors = HashSet::from([1]); | ||||||
|     let mut potential_divisor = 2; |     let mut potential_divisor = 2; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user