Number Theory – Find Last 3 Digits of 2003^{2002^{2001}}

decimal-expansionelementary-number-theorymodular arithmetic

Find The Last 3 digits of the number $2003^{2002^{2001}}$

BY number theory or otherwise,

Also i would like to ask is there a property observed in the numbers of the form $k^n$, where for some $k, n$ is varied then the digits of $k^n$ are periodic,

for example,

$2^n$,
its last digit is periodic with period 4,
its second last digit is periodic $4\cdot 5 = 20$
its third last digit is periodic with periodic with period $20\cdot 5 =100$

I have observed this property with other numbers as well, though period might vary,for different values of $k$.

Best Answer

First, $2003^n \equiv 3^n \mod 1000$.

$3$ is invertible modulo $1000$. The group of invertibles of $\mathbb{Z}/1000\mathbb{Z}$, $(\mathbb{Z}/1000\mathbb{Z})^\times$ has cardinality $\varphi(1000) = 1000 * 1/2 * 4/5 = 400$. This implies that $3^{400} \equiv 1 \mod 1000$, and so $3^n \equiv 3^{n \mod 400} \mod 1000$.

So in order to comptute $2003^{2002^{2001}} \mod 1000$, we need to know $2002^{2001} \mod 400$. $2002^n \equiv 2^n \mod 400$. This time, $2$ is not invertible modulo $400 = 2^4 * 25$. For $n \geq 4$, $2^n$ is always a multiple of $2^4$, so $2^n \mod 400 = (2^4*2^{n-4}) \mod (2^4*25) = 2^4*(2^{n-4} \mod 25)$.

Now, $2$ is invertible modulo 25, and the group $(\mathbb{Z}/25\mathbb{Z})^\times$ has cardinality $\varphi(25) = 25*4/5 = 20$. This implies that $2^{20} \equiv 1 \mod 25$, and so $2^n \equiv 2^{n \mod 20} \mod 25$.

Putting all of this together, we get : $2002^{2001} \mod 400 = 2^{2001} \mod 400 = 2^4 * (2^{1997} \mod 25) = 2^4 * (2^{1997 \mod 20} \mod 25) $ $=2^4 * (2^{17} \mod 25) = 2^4 * (131072 \mod 25) = 2^4 * 22 = 352$.

And finally $2003^{2002^{2001}} \mod 1000 = 3^{352} \mod 1000 = 241$.