3

The answer says it is 1, and I understand why. But why can't I use Fermat's Little Theorem on the exponent like this (by "exponent" I mean the entire $12^{12}$):

$$12^{12} \equiv 1 \pmod{13}$$ Is this not a correct use of Fermat's small theorem? In such case the original problem becomes

$$12^1 \equiv 12 \pmod{13}$$ But this is clearly the wrong answer to $12^{12^{12}} \pmod{13}$.

saner
  • 519

5 Answers5

2

You can, but actually, you're missing that there are two different moduli in using Fermat:

For any $a\not\equiv 0\bmod13$, and any exponent $n$, one has $$a^n\equiv a^{n\bmod 12}\pmod{13}$$ since $a^{12}\equiv 1\bmod 13$, so that, in particular $$12^{12^{12}}\equiv 12^{12^{12}\bmod 12}=12^0=1\pmod{13}.$$ Another way to see it without Fermat is to observe that, since $12\equiv -1\pmod{13}$, one has $12^n\equiv (-1)^n=1\pmod{13}\;$ if $n$ is even.

Bernard
  • 175,478
1

You can use Fermat's theorem in the form $a^{p-1} \equiv 1 \bmod p$ for $a$ not a multiple of $p$. Then $a^{(p-1)k} \equiv 1 \bmod p$ for all $k$ and so $a^{n} \equiv a^{n \bmod (p-1)} \bmod p$.

In your example, this leads you to compute $12^{12} \bmod 12$, which is easy.

lhf
  • 216,483
  • Thanks, yes that's the Fermat's theorem I'm using. Are you sure you don't mean that this leads me to compute $12^{12}$ mod 13? Why mod 12? The p is given in the problem, it's 13. So using Fermat's small theorem on the exponent $12^{12} \equiv 1 $ mod 13, no? By "exponent" I mean the $12^{12}$. – saner Dec 16 '19 at 22:42
  • @eriksan, yes, see my edited answer. – lhf Dec 17 '19 at 00:21
  • $12^{12}\cong0\pmod{12}$, and then $12^0\cong 1\pmod {13}$. –  Dec 17 '19 at 02:30
1

$12^{12}\equiv1\bmod13,$ so $12^{12q+r}\equiv({12}^{12})^q12^r\equiv12^r\bmod13$

J. W. Tanner
  • 60,406
1

But why can't I use Fermat's Little Theorem on the exponent like this:

$$\begin{align} &\ \ \,\color{#0a0}{12^{12} \equiv\, 1}\!\! \pmod{\color{#c00}{\!\!13}}\\ \Rightarrow\ &a^{\Large \color{#0a0}{12^{12}}}\!\!\equiv a^{\Large \color{#0a0}1} \equiv a\!\!\!\pmod{\!13}\end{align}\qquad\qquad$$

You used the wrong modulus $\color{#c00}{13\ {\rm vs.}\ 12\,}$ in the $\rm\color{#0a0}{exponent}$. Correct is, by modular order reduction

by Fermat $\bmod 13\!:\ a\not\equiv0\,\Rightarrow\, a^{\large\color{#c00}{12}}\equiv 1\,\Rightarrow\, a^{\large\color{0a0} N}\!\equiv a^{\large\color{#0a0}N\bmod \color{#c00}{12}}\!\equiv a^{\large\color{#0a0}{12^{12}}\bmod 12}\!\equiv a^{\large\color{#0a0}0}\!\equiv 1$

by using the correct exponent reduction calculation: $\bmod\color{#c00}{12}\!:\ N = \color{#0a0}{12^{\large 12}\!\equiv 0^{\large12}\!\equiv\color{#0a0}0}$

Easier: $\bmod 13\!:\ a\equiv 12\equiv -1\,\Rightarrow\,a^{\large\color{#90f} 2}\equiv (-1)^{\large 2}\equiv 1\,$ so we can take $\,N\bmod\color{#90f} 2\,$ vs. $\!\bmod 12$

Bill Dubuque
  • 272,048
  • Thanks for the link, about modular order reduction, but since I'm a beginner it was a bit over my head.

    What I see from your next-to-last line "by using the correct exponent reduction calculation: mod 12: $=12^{12}≡0^{12}≡0$" that it seems you "subtracted one (1) from the mod given in the problem to calculate the exponent 12^12." Would that be the correct baby-language way of describing what you did?

    – saner Dec 16 '19 at 23:59
  • 1
    @eri As the link explains, we can only reduce the exponent mod $,\color{#c00}n,$ when we know that $,a^{\color{#c00}{\large n}}\equiv 1\pmod{!13}.,$ The reason that $,12=13-1,$ is because little Fermat yields $,a^{\large\color{#c00}{p-1}}\equiv 1\pmod{!p},$ if $,p\nmid a.,$ But there may by such exponents $,\color{#c00}n,$ smaller than $,p-1,$ (the smallest is known as the $\color{#c00}{\textit{order}}$ of $,a,,$ which explains the name modular $\color{#c00}{\textit{order}}$ reduction) $\ \ $ – Bill Dubuque Dec 17 '19 at 00:10
0

When you use Fermat's little theorem, the exponent gets reduced $\pmod{p-1}$, not $\pmod p$.

According to Euler's theorem, a generalization of Fermat's little theorem, you reduce the exponent $\pmod {\varphi (n)}$, where $\varphi $ is Euler's totient function. When $n=p$, we get $\varphi (p)=p-1$.

The reason is that $a^{\varphi (n)}\cong1\pmod n$, in case $(a,n)=1$.

  • We haven't learned the Euler's theorem yet. I'm still a bit confused but it seems like the exponent gets reduced (mod p - 1) if we know that $a^{(p-1)} \equiv 1 $ (mod p), is this right? – saner Dec 17 '19 at 02:31
  • 1
    That's correct, and for that very reason. –  Dec 17 '19 at 02:35