You can put this solution on YOUR website! Hi,
This is quite easy if you know how. The first thing you need to know is the identity.
If your not comfortable with this then try proving it. This identity means we can take the remainder at any time during the multiplication without effecting the result.
We could quite naivly proceed to evalute given . That would take you ages though so I'm going to do some repeated squaring. Google for 'repeated squaring' if you want more information.
I'm going to take modulus 40 after every multiplication. Subbing into this (from bottom up) gives.
So there ya go.
Hope that helps,
Kev