1

I'm given that the formula for Fermat's little theorem: $$ a^{-1} \equiv a^{p-2} \ (mod \ p) $$

I presume I would then be able to get an inverse mod directly from this formula. Let's say $p=7$ and $a=2$, I would naively think that I could do this: $$ 2^{-1} \equiv a^{7-2} \ (mod 7) \\ \Rightarrow 2^{-1} \equiv 32 \ (mod 7) \\ \Rightarrow 2 \cdot 32 \equiv 1 \ (mod 7) \\ \Rightarrow 64 \equiv 1 \ (mod 7) $$

The flow seems good so far.

But when I try to do it backwards with a different number, suddenly the formula doesn't seem to hold anymore. For example:

$$ 8 \equiv 1 \ (mod \ 7) \\ 2\cdot 4 \equiv 1 \ (mod \ 7) \\ \Rightarrow 2^{-1} \equiv 4 \ (mod \ 7) $$

However, this doesn't fit back into the formula: $$ a^{-1} \equiv a^{p-2} \ (mod \ p) \\ 2^{-1} \equiv 4 \ (mod \ 7) \\ 2^{-1} \equiv 2^{7-2} = 2^5 \neq 4 $$

As you can see from the last line, when I put it back into the formula, apparently, I am getting $2^{-1} \equiv 32 (mod7)$ instead of $2^{-1} \equiv 4 (mod 7)$!

But I'm quite sure that $2^{-1} \equiv 4 (mod 7)$ is correct because $2 \cdot 4 = 8 \equiv 1 (mod7)$ looks correct to me. The remainder is indeed $1$ when $8 \div 7$.

Is there something I'm not doing right here? Why does the formula only work for certain numbers only?

xenon
  • 3,438
  • 3
    You sometimes use the syntaxis $\diamond\equiv\bullet \pmod 7$, which means that $7\mid \diamond-\bullet$, and sometimes use the syntaxis $\diamond=\bullet$, which, apparently, strictly means identity of natural numbers for you. What makes you choose one over the other? It's clear that a representative for the class $2^{-1}\pmod 7$ is only determined up to a multiple of $7$, and indeed $32\equiv 4\pmod 7$. – Sassatelli Giulio Jul 26 '22 at 12:49
  • @SassatelliGiulio Oh. I'm so sorry! I'm still very new to this. I might have gotten the syntax wrong? By having $a \equiv b (mod \ 7)$, I'm interpreting it as "the remainder of $a \div 7$ is $b$". The parts where I used the $=$ syntax is only to illustrate that I'm evaluating the fermat's formula directly. Let me know if I'm getting anywhere here wrong. Thanks! – xenon Jul 26 '22 at 12:54
  • 4
    $32\equiv4 \bmod 7$ so there is no problem. Both $32$ and $4$ are different ways of writing the inverse of $2$ modulo $7$. – Jaap Scherphuis Jul 26 '22 at 12:57
  • To expand on Jaap Scherpius' comment: OP finds it confusing that both $2^2$ and $2^5$ are inverses of $2^{-1}$. But $2^5=2^2\cdot2^3$ and $2^3\equiv 1 \bmod 7$. There is a unit buried in there, which is why JS comment is true. – Keith Backman Jul 26 '22 at 16:24
  • @KeithBackman Umm... Am I right to think that if $2^2$ and $2^5$ are inverses of $2^{-1}$, then $2^{-1}\equiv 2^2$ and also $2^{-1}\equiv 2^5$? Also, you mentioned there is a unit buried in there, what is the unit here referring to? So sorry if I'm sounding silly, I think I'm still trying to pick this up as much as I can. – xenon Jul 26 '22 at 16:33
  • You’re interpreting “$a\equiv b\pmod7$” incorrectly. What you want is that this notation means that $b-a$ is a multiple of $7$. Nothing less, and nothing more. – Lubin Jul 26 '22 at 18:42
  • @Lubin When you mention $b-a$ in your notation, does it literally mean b minus a has to be a multiple of 7? Or does it mean both $b$ and $a$ are multiples of 7? – xenon Jul 26 '22 at 20:07
  • It means exactly what I said: $b-a$ is a multiple of $7$. In standard notation, $7|(b-a)$. – Lubin Jul 27 '22 at 14:18

0 Answers0