Section 4.3 The Method of Repeated Squares
Computing large powers can be very time-consuming. Just as anyone can compute or everyone knows how to compute
However, such numbers are so large that we do not want to attempt the calculations; moreover, past a certain point the computations would not be feasible even if we had every computer in the world at our disposal. Even writing down the decimal representation of a very large number may not be reasonable. It could be thousands or even millions of digits long. However, if we could compute something like
The first thing to notice is that any number can be written as the sum of distinct powers of that is, we can write
where This is just the binary representation of For example, the binary representation of 57 is 111001, since we can write
The laws of exponents still work in that is, if and then We can compute in multiplications by computing
Each step involves squaring the answer obtained in the previous step, dividing by and taking the remainder.