The greatest common divisor and least common multiple are often used as simple programming exercises or interview questions.
Since C++17, we finally have the standard versions of these functions as std::gcd and std::lcm in the numeric header.
Click to open in Compiler Explorer.
Leave a comment