In class today, the prof explained Pepin's test, but I got lost midway. This is what I have so far:

Let $\displaystyle F_{n}=2^{2^n}+1$, then $\displaystyle \frac{F_{n}-1}{2}=2^{2^n-1}$ Call this number $\displaystyle q$.

If $\displaystyle 3^q \equiv -1 (mod$ $\displaystyle F_{n})$ (1), then $\displaystyle 3^{2q} \equiv 1(mod$ $\displaystyle F_{n})$. Because of (1), 2q is the order. What I don't understand is how this shows that $\displaystyle F_{n}$ is prime. I also don't get how $\displaystyle F_{n} \equiv 2(mod$ $\displaystyle 3)$.

Any help is much appreciated.