Least common multiple

        /// <summary>
        /// lcm(a, b) = a * b / gcd(a, b)
        /// </summary>
        private static int GetLCM(int a, int b)
        {
            return a * b / GetGCD(a, b);
        }

        private static int GetGCD(int a, int b)
        {
            if (b == 0)
                return a;
            return GetGCD(b, a % b);
        }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s