Experiment with modPow() and mod().