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 entered31000, 1 digit3^{1000},\ 1 \text{ digit}

1\displaystyle \mathtt{1}

Remainder

1(mod10)\displaystyle 1 \pmod{10}
Show the work
  1. The last digits are a remainder

    The last digit of a number is its remainder on division by 101=1010^{1} = 10, so we need 31000 mod 103^{1000} \bmod 10.

  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.

    31≡3(mod10),  32≡9(mod10),  34≡1(mod10),  38≡1(mod10),  316≡1(mod10),  332≡1(mod10),  …3^{1} \equiv 3 \pmod{10},\ \ 3^{2} \equiv 9 \pmod{10},\ \ 3^{4} \equiv 1 \pmod{10},\ \ 3^{8} \equiv 1 \pmod{10},\ \ 3^{16} \equiv 1 \pmod{10},\ \ 3^{32} \equiv 1 \pmod{10},\ \ \ldots
  3. Combining the squares

    The exponent is 1000=512+256+128+64+32+81000 = 512 + 256 + 128 + 64 + 32 + 8, so multiply the matching squares, reducing mod 1010 as you go.

    31000=3512⋅3256⋅3128⋅364⋅332⋅38≡1×1×1×1×1×1≡1(mod10)3^{1000} = 3^{512} \cdot 3^{256} \cdot 3^{128} \cdot 3^{64} \cdot 3^{32} \cdot 3^{8} \equiv 1 \times 1 \times 1 \times 1 \times 1 \times 1 \equiv 1 \pmod{10}
  4. Result

    So the last digit is 11.

Worked examples