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 entered7222, 2 digits7^{222},\ 2 \text{ digits}

49\displaystyle \mathtt{49}

Remainder

49(mod100)\displaystyle 49 \pmod{100}
Show the work
  1. The last digits are a remainder

    The last 22 digits of a number are its remainder on division by 102=10010^{2} = 100, so we need 7222 mod 1007^{222} \bmod 100.

  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.

    71≡7(mod100),  72≡49(mod100),  74≡1(mod100),  78≡1(mod100),  716≡1(mod100),  732≡1(mod100),  …7^{1} \equiv 7 \pmod{100},\ \ 7^{2} \equiv 49 \pmod{100},\ \ 7^{4} \equiv 1 \pmod{100},\ \ 7^{8} \equiv 1 \pmod{100},\ \ 7^{16} \equiv 1 \pmod{100},\ \ 7^{32} \equiv 1 \pmod{100},\ \ \ldots
  3. Combining the squares

    The exponent is 222=128+64+16+8+4+2222 = 128 + 64 + 16 + 8 + 4 + 2, so multiply the matching squares, reducing mod 100100 as you go.

    7222=7128⋅764⋅716⋅78⋅74⋅72≡1×1×1×1×1×49≡49(mod100)7^{222} = 7^{128} \cdot 7^{64} \cdot 7^{16} \cdot 7^{8} \cdot 7^{4} \cdot 7^{2} \equiv 1 \times 1 \times 1 \times 1 \times 1 \times 49 \equiv 49 \pmod{100}
  4. Result

    So the last 22 digits are 4949.

Worked examples