Prove: b passes the Fermat test for $m = p^2$ if and only if $b^{p-1}\equiv 1\pmod {p^2}$

996 Views Asked by At

Question: Let $p$ be a prime and $b$ an integer with $\gcd(b,p) = 1$. Prove: $b$ passes the Fermat test for $m = p^2$ if and only if $b^{p-1}\equiv 1\pmod {p^2}$.

I know that if $b^{p-1}\not\equiv 1\pmod p$, then $p$ cannot be a prime. However I don't know how to carry on proving this. Can someone please help me out with it. Thanks.

1

There are 1 best solutions below

4
On

Not entirely sure I am using the same terminology as you but as I understand it you want to prove that if $p$ is prime and $\gcd(b,p)=1$ then $$b^{p^2-1}\equiv 1\pmod{p^2}\quad\hbox{if and only if}\quad b^{p-1}\equiv1\pmod{p^2}\ .$$ For the "if" direction simply raise both sides to the power $p+1$.

Now assume that $b^{p^2-1}\equiv 1\pmod{p^2}$. Since $p$ is prime we have $b^p\equiv b\pmod p$, which can be written $$b^p=kp+b$$ for some integer $k$. Using the Binomial Theorem, $$b^{p^2}=(b^p)^p=(kp+b)^p=\cdots+\Bigl({p\atop p-2}\Bigr)(kp)^2b^{p-2}+p(kp)b^{p-1}+b^p\ .$$ Now every term on the right hand side has a factor of $p^2$, except the last. So $$b^p\equiv b^{p^2}\pmod{p^2}\ .$$ Cancelling $b$, which is possible since $\gcd(b,p)=1$, and using our initial assumption, $$b^{p-1}\equiv b^{p^2-1}\equiv 1\pmod{p^2}\ .$$