C# Chocolates By Numbers
static long ChocolatesByNumbers(long n, long m)
{
long Gcd(long x, long y) => x % y == 0 ? y : Gcd(y, x % y);
return (n * m) / Gcd(n, m) / m;
}
This uses the greatest common divisor to figure out how many chocolates get eaten before the pattern repeats.