Step by step
The question
Question: find 5⁹⁹ mod 12.
5 to the power 99 has 70 digits.
Too big to work out by hand.
1 Small powers first
Let's make a table of small powers.
Each one is the one before times 5.
We only keep the remainder: the big part never matters.
5 to the 1 is 5.
Then 5 times 5 is 25.
25 mod 12 is 1.
And so on.
2 Find the pattern
At k = 3 we are back to 5.
From here everything repeats.
So the pattern 5, 1 repeats every 2 powers.
3 Where 99 lands
99 divided by 2: 49 full patterns, and 1 left over.
Careful!
The pattern is all we need.
The full number is far too big.
So 5 to the 99 is like k = 1.
So 5⁹⁹ mod 12 is 5.
4 Check
A computer can work out all 70 digits: 157772, and so on, 8125.
Divided by 12, it leaves 5, the same as our pattern.
Right!
Let's look back.
First: small powers first.
Then: find the pattern.
Then: where 99 lands.
Last: check.