0

For the proof of Fermat's Little Theorem, it ends up being that

$(p-1)!\cdot a^{(p-1)} \equiv (p-1)!\pmod{p}$ then since $p ∤ (p-1)!$ when $p$ is prime

$a^{(p-1)} \equiv 1 \pmod{p}$

(as seen here)

I understand why $p ∤ (p-1)!$ when $p$ is prime and why it fails when $p$ is composite, however, there exists (the only?) exception which is $4$. (as $4 ∤ 3!$)

So then why is it that Fermat's Little Theorem doesn't work when $p = 4$ and $(a,4) = 1?$

i.e. why is $7^{(4-1)} \equiv 1 \pmod{4}$ not true, despite it satisfying the conditions of the proof

Thank you

(Apologies if it is just something stupid that I have overlooked)

Arturo Magidin
  • 417,286
  • 4 is not a prime number. – Aaron Jul 26 '22 at 19:20
  • @Aaron I am aware, the point I'm making is that it is implied p has to be prime, so that p does not divide (p-1)!, however 4 has this property while not being prime, so why is it that it does not work when p=4 – TheyWereConnected Jul 26 '22 at 19:24
  • You have that the very last line of the proof would work when p=4, but what about all of the other lines in the proof? – Aaron Jul 26 '22 at 19:26
  • @Aaron Copied: Consider the reduced residue system modulo p, where p is prime. It's {1,2,…p−1}. Multiply all numbers by a, s.t. gcd(a,p)=1. Then we obtain the set {a,2a,…(p−1)a}. We'll prove that this set also represent the reduced residue system modulo p. It's enough to show that the numbers are unique modulo p. If we have that na≡ma(modp). Then we have that p∣(n−m)a⟹p∣(n−m), by Euclid's Lemma as gcd(a,p)=1. But obviously |n−m|≤p−1 so we must have n=m. Now multiplying all elements from the two reduced residue systems we have:

    (p−1)!≡a⋅2a⋯(p−1)a≡ap−1(p−1)!(modp)⟹ap−1≡1(modp)

    – TheyWereConnected Jul 26 '22 at 19:29
  • @Aaron that is copied and pasted from the second answer here: https://math.stackexchange.com/questions/2536229/why-need-prime-number-in-fermats-little-theorem – TheyWereConnected Jul 26 '22 at 19:29
  • 1
    The linked proof breaks in multiple places when $p$ is composite: we need $a$ coprime to $p$ for $x\to ax$ to be a bijection mod $p$, and we need to restrict the residues to those coprime to $p$ if we want their product to be coprime to $p$ (so cancellable). Doing so generalizes the argument to a proof of Euler's Theorem $,a^{\phi(n)}\equiv 1\pmod{!n},$ if $a$ is coprime to $n.\ \ $ – Bill Dubuque Jul 26 '22 at 19:32
  • Actually, looking closer, the last line of the proof doesn't work here. Yes, it is true that 4 does not divide 3!, but 3! is not invertible mod 4, because 3! is not relatively prime to 4. So you can't divide both sides by 3!. – Aaron Jul 26 '22 at 19:33
  • @aaron Thank you very much, I overlooked that – TheyWereConnected Jul 26 '22 at 19:38
  • @BillDubuque Thank you – TheyWereConnected Jul 26 '22 at 19:38
  • Only the integers that are coprime with $n$ are invertible mod $n$, and $(n-1)!$ is coprime with $n$ if and only if $n$ is prime (or $1$). So for a non-prime an identity $(n-1)!a^{n-1}\equiv (n-1)!\pmod n$ implies that $a^{n-1}\equiv 1\pmod{\frac n{\operatorname{gcd}(n,(n-1)!)}}$ which is a weaker condition than $a^{n-1}\equiv 1\pmod n$. For instance, for $n=4$ you just obtain that $a^3\equiv 1\pmod 2$ for all odd integers, which incidentally is also true: for instance, $3^3\equiv -1\pmod 4$. Unfortunately it isn't quite the assertion you where expecting mod $4$. – Sassatelli Giulio Jul 26 '22 at 19:40
  • @SassatelliGiulio Thank you very much – TheyWereConnected Jul 26 '22 at 19:46
  • Note: if you know group theory then you can view this as a special case of Lagrange's Theorem, e.g. see here (also mentioned in a deleted answer). Similarly for Wilson's theorem, e.g. see here. – Bill Dubuque Jul 26 '22 at 19:53
  • Since the generalized proof mentioned in my prior comment has already been posted, I am closing this as a dupe of that. Someone might like to add a clearer complete proof there. – Bill Dubuque Jul 26 '22 at 20:09

0 Answers0