Rust Chocolates By Numbers
fn gcd(n: i64, m: i64) -> i64 {
if n % m == 0 { m } else { gcd(m, n % m) }
}
fn chocolates_by_numbers(n: i64, m: i64) -> i64 {
(n * m) / gcd(n, m) / m
}
This uses the greatest common divisor to figure out how many chocolates get eaten before the pattern repeats.