You'll see a fair number of easy mathy problems whose solutions involve finding and using the Greatest Common Divisor (GCD) of some numbers. The Euler totient function is rarer, but it is still good to know.
Reading material:
- Euclid's algorithm
- CPH Ch 21, pg 200
- CP Algorithms
- Euler's totient function
- CPH Ch 21, pg 201
- CP Algorithms
- Topcoder article - click
Tip: Use std::gcd or __gcd() (a builtin function of the GCC compiler).