Project Euler #122: Efficient exponentiation