 To find a very high power of a number mod n, we can use the fast powering algorithm. This first appeared in the work of Bengala, an Indian mathematician, in the third century BC. Bengala also coded the algorithm in what is arguably the oldest computer programming language. The fast powering algorithm works as follows. To find a to power n, we do the following. We start with a and square it repeatedly to get a sequence of powers. a, a squared, a to the fourth, a to the eighth, and so on. And then we select the terms in the sequence that multiply to a to the n. Now, Bengala's algorithm was actually more efficient than this, but we won't worry about that increase in efficiency for our purposes. So for example, let's say we want to find 2 to the tenth power. We find that 2 is equal to 2, and now we'll square. 2 squared is 4, 4 squared. Well, that's 2 squared squared. So we know that 4 squared is 16, and over on the right-hand side, we have 2 to the fourth. If we square 16, well, that's really 2 to the fourth squared, or 2 to the eighth. And since we want to find 2 to the tenth, well, that's really 2 to the eighth times 2 to the second, or 4 times 256, and that gives us... Now, if you're finding the powers of an integer, Bengala's algorithm is slightly more efficient than repeated multiplication. However, because it requires squaring large numbers, it's not significantly less tedious. But if you're working mod n, you can always reduce a result to a number less than n, and this makes it much more efficient. For example, let's find 3 to the 27 mod 100. So 3 is congruent to 3. 3 squared is 9. 3 to the fourth is 81. And since these are all less than 100, they can't be reduced. Now, if we square 3 to the fourth, that's 81 squared. Over on the left, we get 3 to the eighth, and the right, the numerical value is 6561, but we can reduce that mod 100. Squaring both sides, 3 to the eighth squared, well, that's 3 to the 16th. We'll find 61 squared, and then reduce it mod 100 to 21. Now we want to find 3 to power 27 mod 100. So first, we need to pick out the powers of 3 that will multiply to 3 to the 27. So we need the 16th, the eighth, the second, and a single factor of 3. And we'll multiply the corresponding numbers 21, 61, 9, and 3. And we can multiply these numbers together and reduce mod 100 to... Let's find 67 to the 153rd power mod 257. So we use repeated squaring. 67 is congruent to 67. 67 squared is... And we can reduce that to 120. Now if we square 67 squared, we get 67 to the fourth, that's 120 squared. And we can reduce that mod 257 all the way down to 8. 67 to the fourth squared, well, that's 67 to the eighth, while 8 squared is 64. 67 to the eighth squared is 64 squared, which we can reduce. 67 to the 16th squared, 67 to the 32nd squared. And an interesting thing happens now that we've gotten a 1, because any further squaring is just going to give us 1. So 67 to the 128th is 1. And now we need to select the powers that give us 153. So we need the 128th. If we include the 64th or the 32nd, that puts us too high. So the next power we need to include is the 16th power, then the 8th power, and finally the first power. And so 67 to the 153rd is the product of these four numbers. Now remember, working mod n means you could always reduce a number to a value less than n. So if we multiply 64 times 67, we get 4,288. But to keep our numbers from getting too large, we can reduce that to 176. We still have to multiply by 241, and so we get, which we then reduce to 11, giving us our final answer.