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 entered2100, 3 digits2^{100},\ 3 \text{ digits}

376\displaystyle \mathtt{376}

Remainder

376(mod1000)\displaystyle 376 \pmod{1000}
Show the work
  1. The last digits are a remainder

    The last 33 digits of a number are its remainder on division by 103=100010^{3} = 1000, so we need 2100 mod 10002^{100} \bmod 1000.

  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(mod1000),  22≡4(mod1000),  24≡16(mod1000),  28≡256(mod1000),  216≡536(mod1000),  232≡296(mod1000),  …2^{1} \equiv 2 \pmod{1000},\ \ 2^{2} \equiv 4 \pmod{1000},\ \ 2^{4} \equiv 16 \pmod{1000},\ \ 2^{8} \equiv 256 \pmod{1000},\ \ 2^{16} \equiv 536 \pmod{1000},\ \ 2^{32} \equiv 296 \pmod{1000},\ \ \ldots
  3. Combining the squares

    The exponent is 100=64+32+4100 = 64 + 32 + 4, so multiply the matching squares, reducing mod 10001000 as you go.

    2100=264⋅232⋅24≡616×296×16≡376(mod1000)2^{100} = 2^{64} \cdot 2^{32} \cdot 2^{4} \equiv 616 \times 296 \times 16 \equiv 376 \pmod{1000}
  4. Result

    So the last 33 digits are 376376.

Worked examples