Last Digits of a Power Calculator
Enter the base, the exponent and how many last digits you want.
A whole number.
A whole number, 0 or more.
How many last digits, from 1 to 20.
Try
Result
You entered
Remainder
Show the work
The last digits are a remainder
The last digit of a number is its remainder on division by , so we need .
Repeated squaring
Squaring over and over, and reducing mod the modulus each time, keeps every number small. Writing the exponent as a sum of powers of then shows which of these squares to multiply together.
Combining the squares
The exponent is , so multiply the matching squares, reducing mod as you go.
Result
So the last digit is .