# What is $2012^{2011}$ modulo $14$?

$$2012^{2011} \equiv x \pmod {14}$$

I need to calculate that, all the examples I've found on the net are a bit different. Thanks in advance!

-
How do I compute $a^b\,\bmod c$ by hand? Should this be closed as a duplicate? – Martin Sleziak Jun 23 '13 at 10:07

By the Chinese remainder theorem, knowing what something is modulo $2$ and what it is modulo $7$ is equivalent to knowing what it is modulo $14$.

Clearly, $2012^{2011}\equiv 0\bmod 2$.

Next, note that because$$2012\equiv 3\bmod 7$$ we have $$2012^{2011}\equiv 3^{2011}\bmod 7.$$ By Fermat's little theorem, we know that $$3^6\equiv 1\bmod 7$$ so that $$2012^{2011}\equiv 3^{2011}\equiv 3^{(6\cdot 335)+1}\equiv (3^6)^{335}\cdot 3\equiv 3\bmod 7.$$ Putting this back together with the help of the Chinese remainder theorem (or just direct observation if you prefer) we see that $$2012^{2011}\equiv 10\bmod 14.$$

-
How do you guess if its 6, 12, or 10? – Daniel Margolis Jun 23 '13 at 6:54
@Daniel: There is no guessing - neither $6$ or $12$ equivalent to $3$ modulo $7$. Go through each of the numbers $$0,\;1,\;2,\;3,\;4,\;5,\;6,\;7,\;8,\;9,\;10,\;11,\;12,\;13$$ and check which ones are equivalent to $0$ modulo $2$ and which are equivalent to $3$ modulo $7$. You will see that $10$ is the only one that is both. It may also help you to read the Wikipedia article on the Chinese remainder theorem. – Zev Chonoles Jun 23 '13 at 7:04
Is it always just one? – Daniel Margolis Jun 23 '13 at 7:07
@Daniel: If $n$ and $m$ are relatively prime integers, then for any choice of $a$ and $b$, the system \begin{align*} x&\equiv a\bmod m\\ x&\equiv b\bmod n \end{align*} has exactly one solution $x$ within the range $$0,\;1,\;\ldots,\;mn-1.$$ In the case under discussion, we had $m=2$, $n=3$, $a=0$, and $b=3$. This statement can be generalized to more than two moduli; the Wikipedia article contains more information. – Zev Chonoles Jun 23 '13 at 7:10

Observe that $2012$ is $10$ mod $14$.

The powers of $10$ mod $14$ are: $10, 2, 6, 4, 12, 8$, after which they cycle.

Given the six remainders above, we now consider $10^{2011}$ mod $14$.

Since $2011 = 6 \cdot 335 + 1$, the expression cycles through the six remainders $335$ times, before finally stopping back on the first remainder: $10$.

Therefore, $2012^{2011}$ mod $14 = 10^{2011}$ mod $14 = 10$ mod $14$.

-
This is a nice and simple solution, that any schoolchild can understand. – Erel Segal-Halevi Jun 23 '13 at 4:07
@ErelSegalHalevi "any schoolchild" is a bit of a stretch, but one certainly does not need to appeal (directly) to the Chinese Remainder Theorem or Fermat's Little Theorem. (Surely there are even simpler ways than what I've written out above.) – Benjamin Dickman Jun 23 '13 at 4:20

As $(2012,7)=1$ using Fermat's Little Theorem $2012^6\equiv1\pmod 7$

$$\text{As } 2010\equiv0\pmod 6, 2012^{2010}\equiv1 \pmod 7=1+7a\text{ for some integer }a$$

$$\implies 2012^{2011}=2012\cdot 2012^{2010}=2012(1+7a)\equiv2012\pmod{14}$$

$$\text{Now,} 2012=2100-88\equiv-88\equiv10\pmod{14}$$

-

Using my own programming language from the shell command line:

$txr -c "@(bind a @(exptmod 2012 2011 14))" a="10"  How that works internally is in binary. The exponent 2011 is considered to be a sum of powers of two. It's better to use a simpler example, like$13^{11} \mod 5$, which is$13^{8 + 2 + 1} \mod 5$which is$13^813^213 \mod 5$. The factors are evaluated by repeated squaring, and reducing modulo 5, so the intermediate product is always in the range 0 to 4. If we square$13$we get$13^2$. If we square that again we get$13^4$. If we square that, we get$13^8$. Repeated squaring gets us the power of two exponents, and we multiply together those ones which correspond to the powers of two present in the exponent, all modulo our modulus. Although this is part of the bignum support, calculating$2012^{2011}\mod 14$does not invoke any bignums. Repeatedly squaring$2012$and reducing modulo$14\$ can be done with 32 bit integer arithmetic.

-