2

I'm trying to solve the following exercise: $$2017^{2016^{2015}} \mod 1000,$$ here's what I've already come up with: Using Euler's conrgruence, one finds that $$2017^{2016^{2015}} \equiv 2017^{2016^{2015}\mod \phi(1000)}\mod 1000,$$ where $\phi$ is the Euler function, with $\phi(1000) = 400.$ Because $\gcd(400,2016) \neq 1$, Euler isn't directly applicable. Instead, I did this (I've found this method somewhere online, so I don't know if this is correct): $$2016^{2015} \mod 400 = (2016^{2015 \mod \phi(25)} \mod 25) \mod 400,$$ and therefore, $$2016^{2015} \mod 400 = (2016^{15} \mod 25) \mod 400.$$ However, I don't have any idea on how to continue further. Any thoughts?

Thanks!

Drive
  • 21
  • I think the idea that you found online is this: to calculate $x^y$ mod $400$, you calculate $x^y$ mod $25$ (which is equal to $x^{y \mod \phi(25)}$ mod $25$), and $x^y$ mod $16$ (which is equal to $x^{y \mod \phi(16)}$ mod $16$). Then combine them (easy in your case, because $x = 0$ mod $16$). – TonyK Aug 23 '15 at 11:53

3 Answers3

4

As $2017$ is coprime to $1000$, we have $2017^{2016^{2015}}\equiv2017^{2016^{2015}\bmod\varphi(1000)}\mod 1000$.

  • As $\varphi(1000)=\varphi(2^3\cdot 5^3)=400$, we first have to compute $2016^{2015}\bmod 400=16^{2015}\bmod 400$.

Now $16$ divides $400$, so we can't reduce the exponent modulo $400$. We'll use the Chinese Remainder theorem for the computation. From $400=16\cdot25$ and the factors are coprime, we know that $$\mathbf Z/400\mathbf Z\simeq\mathbf Z/16\mathbf Z\times\mathbf Z/25\mathbf Z.$$ Hence if we know $16^n\bmod 16$ (which is $0$) and $16^n\bmod 25$, the reverse isomorphism will give us $16^n\bmod400$. Now this reverse isomorphism is derived from a Bézout relation between $16$ and $25$. Such a relation is obtained from the Extended Euclidean algorithm and we have: $$11\cdot 16-7\cdot 25=1.$$ The reverse isomorphism is then given by: $$(\alpha,\beta)\longmapsto \beta\cdot 11\cdot 16+\alpha\cdot(-7)\cdot25.$$ In the present case, $\alpha=0$, hence $16^n\equiv(16^n\bmod25)\cdot176\mod400$.

Observe $16$ has order $5$ modulo $25$: indeed $\;16^2=256\equiv 6\mod 25$, hence $\;16^4\equiv 6^2\equiv 11\mod25$, and finally $\;16^5\equiv 11\cdot 16\equiv 1\mod25$ Consequently, $16^{2015}=\bigl(16^5\bigr)^{403}\equiv 1\mod 25$.

Thus $\;2016^{2015}\bmod 400\equiv 16^{2015}\equiv 176\mod 400$

  • Let's go back to the initial problem: $2017^{2016^{2015}}\equiv 17^{2016^{2015}\bmod400}\equiv17^{176}\mod 1000$.

We will use again the Chinese Remainder theorem: as $17\equiv 1\mod 8$, $\;17^{176}\equiv \color{red}{1}\mod8$ too.

Modulo $125$, $\;17^{176}\equiv17^{176\bmod\varphi(125)}=17^{76}$. The fast exponentiation algorithm results in $\;17^{176}\equiv \color{red}{31}\mod 125$. As a Bézout's relation between $8$ and $125$ is: $$47\cdot 8-3\cdot 125=1,$$ we obtain that $$17^{176}\equiv \color{red}{31}\cdot 47\cdot8- \color{red}{1}\cdot3\cdot 125=31\cdot376-375=281 \mod 1000. $$

Bernard
  • 175,478
2

As $\displaystyle2017\equiv17\pmod{1000},2017^m\equiv17^m$ for any integer $m$

Use Carmichael function, $\lambda(1000)=100$

$$\implies17^{(2016^{2015})}\equiv17^{(2016^{2015})\pmod{100}}\pmod{1000}$$

Now $2016\equiv16\implies2016^{2015}\equiv16^{2015}\pmod{100}$

As $(16,100)=4$ let use find $16^{2015-1}\pmod{100/4}$

$16^{2014}=(2^4)^{2014}=2^{8056}$

As $\displaystyle\lambda(25)=\phi(25)=20$ and $8056\equiv16\pmod{20},2^{8056}\equiv2^{16}\pmod{25}$

$2^8=256\equiv6\pmod{25}\implies2^{16}\equiv6^2\equiv11$

$\implies16^{2014}\equiv11\pmod{25}$

$\implies16^{2014+1}\equiv11\cdot16\pmod{25\cdot16}\equiv176\pmod{400}\equiv76\pmod{100}$

$$\implies17^{(2016^{2015})}\equiv17^{76}\pmod{1000}$$

Now $$17^{76}=(290-1)^{38}=(1-290)^{38}\equiv1-\binom{38}1290+\binom{38}2290^2\pmod{1000}$$

Now $\displaystyle38\cdot29=(40-2)(30-1)\equiv2\pmod{100}\implies\binom{38}1290\equiv20\pmod{1000}$

and $\displaystyle\binom{38}229^2=\dfrac{38\cdot37}2(30-1)^2\equiv3\pmod{10}$

$\displaystyle\implies\binom{38}2290^2\equiv3\cdot100\pmod{10\cdot100}$

0

Claim: If $x$ is relatively prime to $1000$, $x^{100}\equiv 1\pmod{1000}$.

Proof:

Consider the group of units/totatives of $1000$ under multiplication modulo $1000$.

By direct product decomposition following the theorems listed in this post, $$\begin{align}U(1000)&\cong U(5^3)\times U(2^3)\\ &\cong \mathbb Z_{100}\times\mathbb Z_{2}\times \mathbb Z_{2}\end{align}$$

$(100\mathbb Z+1,\ 2\mathbb Z+1, \ 2\mathbb Z+1)$ is a maximal order element in the decomposed group which has an order of $\text{LCM}(100,2,2)=100$.

Thus, it follows from isomorphism that for all $x\in U(1000)$, $x^{100}=1\tag*{$\blacksquare$}$


Now it's easy to see that:

$$2017^{2016^{2015}}\equiv 17^{2016^{2015}\mod 100}\pmod{1000}$$

Let's deal with the exponent. $$2016^{2015}\equiv 16^{2015}= 2^{8060}\pmod {100}$$

We can find $2^{8060}\mod 100$ with help of the Chinese Remainder Theorem.

We have the system: $$\begin{cases}2^{8060}\equiv 0\pmod 4\\ 2^{8060}\equiv (2^{\varphi(25)})^{403}\equiv 1\pmod{25} \end{cases}$$ solving which yields $2^{8060}\equiv -24\pmod{100}$

$\therefore\ 2016^{2015}\equiv 76\pmod{100}$


So far we have concluded: $$2017^{2016^{2015}}\equiv 17^{76}\pmod{1000}$$

Now all we need to do is find $17^{76}\mod 1000$.

Unfortunately, for us, $17$ is one of those maximal order elements in $U(1000)$ so there's no shortcut in evaluating it... I attempted to use Chinese remainder theorem, however, finding $17^{76}\mod 125$ is difficult because $17$ is a generator of $U(125)$.

I took to python and found the answer is $281$.

>>> x=1
>>> for i in range(76): x=(x*17)%1000
...
>>> x
281

Update: We can find $17^{76}\mod 125$ using binomial theorem pretty easily.

Here's my line of thought:

$$ \begin{align}17^{76} &= (5^2-2^3)^{76}\\ &\equiv (2^3)^{76} - 76\times 5^2\times (2^3)^{75}\\ & \equiv 2^{28}-76\times 25\times 2^{25}\\ &\pmod{125}\end{align}$$

$$ \begin{align} 2^{25} &= (2^7)^3\times 2^4\\ & \equiv 3^3\times 16\\ &\equiv 57\\ &\pmod{125}\end{align} $$

$$\begin{align} 2^{28} &= (2^7)^4\\ & \equiv 3^4\\ &= 81\\ &\pmod{125}\end{align}$$

$$ \begin{align} 17^{76} &\equiv 81-76\times 25\times 57\\ &\equiv 81+76\times 100\times 57\\&\equiv 81+1\times 100\times 2 \\& \equiv 281\\& \pmod{125}\end{align}$$

$$ 17\equiv 1\implies 17^{76}\equiv 1\equiv 281\pmod{8} $$

Now we have this system. $$ \begin{cases} 17^{76}\equiv 281\pmod{125}\\ 17^{76}\equiv 281\pmod{8} \end{cases}$$

$$\therefore17^{76}\equiv 281\pmod{1000}$$

Conclusion: $$\boxed{2015^{{2016}^{2017}}\equiv 281 \pmod{1000}}$$