The article 'Public Key
Cryptography ' gives a detailed explanation of how the method
works and gives you help in working with modulus arithmetic.
This problem simply asks you to work out
which has to be done in stages because calculators and computers
will not handle big numbers like
.
David of Colyton Grammar School gave the very neat solution
you see below and also wrote a program to check the answer and to
calculate quickly other high powers in modulus arithmetic. Try out David's program.
In order to calculate
you have to find a
sensible way to break down
into pieces which can all be
tackled individually. The easiest way of doing this I think is to
first write 59 as a sum of powers of 2: 59 = 32+16+8+2+1
Now you know that
This is very useful because in the
sequence
each
term is the square of the previous term.
You also need to appreciate that in modular arithmetic:
This makes the numbers that you
are going to have to deal with far more manageable and the problem
can be written like this:
|
|
Now we can express
as
. This can be done easily
using normal modular multiplication:
|
|
So now we have the final answer:
. This
method is good because as soon as the modular base is fixed there
becomes a ceiling for how large the numbers that we have to
compute can be. The largest number that will ever need to be
computed is the square of one less than the modular base.
I have also written a console application to check my answer and
to quickly calculate any other similar problems. It can do any
number and mod with powers up to 255. As it was written in a rush
it may still be slightly buggy but seems to work well every time
I've tried it ;)
Andrei from Bucharest Romania gave a method which depends on expressing
as a
product and working out the factors separately.
|
|
Working modulo 391 this becomes
|
|
Program to
calculate powers in modulus arithmetic