Modular exponentiation solution