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 entered210, 5 digits2^{10},\ 5 \text{ digits}

01024\displaystyle \mathtt{01024}

Leading zeros are kept to show 5 digits.

Remainder

1024(mod100000)\displaystyle 1024 \pmod{100000}
Show the work
  1. The last digits are a remainder

    The last 55 digits of a number are its remainder on division by 105=10000010^{5} = 100000, so we need 210 mod 1000002^{10} \bmod 100000.

  2. 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 22 then shows which of these squares to multiply together.

    21≡2(mod100000),  22≡4(mod100000),  24≡16(mod100000),  28≡256(mod100000)2^{1} \equiv 2 \pmod{100000},\ \ 2^{2} \equiv 4 \pmod{100000},\ \ 2^{4} \equiv 16 \pmod{100000},\ \ 2^{8} \equiv 256 \pmod{100000}
  3. Combining the squares

    The exponent is 10=8+210 = 8 + 2, so multiply the matching squares, reducing mod 100000100000 as you go.

    210=28⋅22≡256×4≡1024(mod100000)2^{10} = 2^{8} \cdot 2^{2} \equiv 256 \times 4 \equiv 1024 \pmod{100000}
  4. Result

    So the last 55 digits are 0102401024.

Worked examples