Euclid's two-thousand-year-old algorithm for finding the greatest common divisor.
(x: u64, y: u64)
| 76 | |
| 77 | // Euclid's two-thousand-year-old algorithm for finding the greatest common divisor. |
| 78 | fn gcd(x: u64, y: u64) -> u64 { |
| 79 | let mut x = x; |
| 80 | let mut y = y; |
| 81 | while y != 0 { |
| 82 | let t = y; |
| 83 | y = x % y; |
| 84 | x = t; |
| 85 | } |
| 86 | x |
| 87 | } |
| 88 | |
| 89 | /// Enum describing the outcomes of a `reduce()` call on a `TokenBucket`. |
| 90 | #[derive(Clone, Debug, PartialEq)] |