Maths Olympiad Prep

Library / Brazilian Math Olympiad /50 of 66

Brazilian Math Olympiad

Number theory Difficulty 6.6 National Olympiad Prove it Brazil

What is the smallest positive integer nn such that there exists a positive integer kk such that the last 2012 digits of nkn^k are all equal to 1?

Solution

Answer: 71.

Since 11…1⏟2012 ones=102012−19\underbrace{11\dots1}_{2012 \text{ ones}} = \frac{10^{2012}-1}{9}, the problem is equivalent to finding the smallest nn such that, for some kk,
nk≡102012−19(mod102012)9nk≡−1(mod102012)  ⟺  n−k≡−9(mod102012)  ⟺  {n−k≡−9(mod22012)n−k≡−9(mod52012) \begin{align*} n^k &\equiv \frac{10^{2012} - 1}{9} \pmod{10^{2012}} \\ 9n^k &\equiv -1 \pmod{10^{2012}} \\ &\iff n^{-k} \equiv -9 \pmod{10^{2012}} \\ &\iff \left\{ \begin{array}{l} n^{-k} \equiv -9 \pmod{2^{2012}} \\ n^{-k} \equiv -9 \pmod{5^{2012}} \end{array} \right. \end{align*}

Let's look at n−k mod 8n^{-k} \bmod 8 first. It's immediate that nn is odd. Since 12≡32≡52≡72≡1(mod8)1^2 \equiv 3^2 \equiv 5^2 \equiv 7^2 \equiv 1 \pmod 8, we must have n≡7(mod8)n \equiv 7 \pmod 8 and −k-k odd. Now look at it mod 16: let k=−mk = -m and n=8u−1n = 8u - 1. Then
(8u−1)m≡−1+8um(mod16) (8u - 1)^m \equiv -1 + 8um \pmod{16}

and
nm≡−9(mod16)8um−1≡−9(mod16)  ⟺  um≡1(mod2), \begin{align*} n^m &\equiv -9 \pmod{16} \\ 8um - 1 &\equiv -9 \pmod{16} \\ &\iff um \equiv 1 \pmod{2}, \end{align*}

that is, uu is odd. Therefore n=8(2t+1)−1≡7(mod16)n = 8(2t + 1) - 1 \equiv 7 \pmod{16}.

Now look at n−k mod 5n^{-k} \bmod 5: since −k-k is odd, and 13≡1(mod5)1^3 \equiv 1 \pmod 5, 23≡3(mod5)2^3 \equiv 3 \pmod 5, 33≡2(mod5)3^3 \equiv 2 \pmod 5 and 43≡4(mod5)4^3 \equiv 4 \pmod 5, we must have n≡1(mod5)n \equiv 1 \pmod 5. Putting everything together, we have n≡7(mod16)n \equiv 7 \pmod{16} and n≡1(mod5)  ⟹  n≡71(mod80)n \equiv 1 \pmod 5 \implies n \equiv 71 \pmod{80}, and thus n≥71n \ge 71.

We claim that n=71n = 71 does the job. First notice that, by the Lifting the Exponent lemma, ν2(71N−1)=ν2(712−1)+ν2(N)−1=ν2(N)+3\nu_2(71^N - 1) = \nu_2(71^2 - 1) + \nu_2(N) - 1 = \nu_2(N) + 3 and ν5(71N−1)=ν5(71−1)+ν5(N)=ν5(N)+1\nu_5(71^N - 1) = \nu_5(71 - 1) + \nu_5(N) = \nu_5(N) + 1.

Now, notice that this implies 71v≡71w(mod2t)71^v \equiv 71^w \pmod{2^t}   ⟺  71v−w≡1(mod2t)\iff 71^{v-w} \equiv 1 \pmod{2^t}   ⟺  ν2(v−w)+3≥t  ⟺  2t−3∣v−w  ⟺  v≡w(mod2t−3)\iff \nu_2(v-w) + 3 \ge t \iff 2^{t-3} \mid v-w \iff v \equiv w \pmod{2^{t-3}}. We analyze now the possible residues of 71N(mod2t)71^N \pmod{2^t}: first, we know that 71≡7(mod16)71 \equiv 7 \pmod{16}, and 712≡1(mod16)71^2 \equiv 1 \pmod{16}, so all residues 71N(mod2t)71^N \pmod{2^t} are congruent to either 1 or 7(mod16)7 \pmod{16}, so one eighth of the residues appear, in a total of 2t−32^{t-3} residues. But 71v≡71w(mod2t)71^v \equiv 71^w \pmod{2^t}   ⟺  v≡w(mod2t−3)\iff v \equiv w \pmod{2^{t-3}}, so there are at most 2t−32^{t-3} residues. This means that the residues are all numbers congruent to 1 or 7(mod16)7 \pmod{16}. So, for all t≥4t \ge 4 there is NN such that 71N≡−9(mod2t)71^N \equiv -9 \pmod{2^t}. Notice that NN is unique mod 2t−32^{t-3}.

The same argument applies mod 5t5^t: all residues of 71N(mod5t)71^N \pmod{5^t} are congruent to 1(mod5)1 \pmod 5 and 71v≡71w(mod5t)  ⟺  71v−w≡1(mod5t)  ⟺  ν5(v−w)+1≥t  ⟺  5t−1∣v−w  ⟺  v≡w(mod5t−1)71^v \equiv 71^w \pmod{5^t} \iff 71^{v-w} \equiv 1 \pmod{5^t} \iff \nu_5(v-w) + 1 \ge t \iff 5^{t-1} \mid v-w \iff v \equiv w \pmod{5^{t-1}}. One fifth of the residues appear, all of them congruent to 1 mod 5. So the residues are all numbers congruent to 1 mod 5, and for all t≥2t \ge 2 there is NN such that 71N≡−9(mod5t)71^N \equiv -9 \pmod{5^t}. Notice that NN is unique mod 5t−15^{t-1}.

We can finish the problem now: we only need to find NN that is congruent to a number mod 2t2^t and to a number mod 5t5^t, but it exists due to the Chinese remainder theorem. Now plug t=2012t = 2012.

Want a route through all this instead of an archive? The track puts 2,604 problems in a working order, from Junior Challenge level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.