The product of integers relatively prime to $n$ congruent to $\pm 1 \pmod n$

Problem: Let $1 \leq b_1 < b_2 <...< b_{\phi(n)} < n$ be integers relatively prime with n.Prove that

$$B_n = b_1 b_2 ... b_{\phi(n)} \equiv \pm 1 \bmod n $$

I was thinking of Fermat's Little Theorem or Euler's Theorem.


The cases $n=1$ and $n=2$ are trivial, so we can assume that $n\gt 2$.

As Calvin Lin suggested, for every $x$ in your list, there is a unique number $y$ in the list such that $xy\equiv 1\pmod{n}$.

If $y\ne x$, call the set $\{x,y\}$ a couple. By definition, the product of the two numbers in a couple is congruent to $1$ modulo $n$. So the product of the coupled numbers is congruent to $1$ modulo $n$.

Now we deal with the singles, the people $x$ such that $x^2\equiv 1\pmod{n}$.

Note that if $x$ is single, then so is $n-x$. Moreover, since $n\gt 2$, the numbers $x$ and $-x$ are not congruent modulo $n$. For if they were, then $2x$ would be divisible by $n$. This is not possible, since $x$ is relatively prime to $n$ and $n\gt 2$.

So there is some romance in the world of singles, they can be paired off in pairs $\{x,n-x\}$ whose product is congruent to $-x^2$, that is, to $-1$.

We conclude that if $2k$ is the number of singles, then the product of the singles is congruent to $(-1)^k$ modulo $n$.

Thus the product of all our $b_i$ is congruent to $(-1)^k$ modulo $n$. The result follows.

Remark: If $n$ is odd then the number of singles is $2^l$, where $l$ is the number of distinct primes in the prime power factorization of $n$. In the very special case of an odd prime $n$, there are $2$ singles, and we get Wilson's Theorem. In all other cases the number of singles is divisible by $4$, so our product is congruent to $1$ modulo $n$. it is not hard to extend the detailed analysis of when our product is congruent $1$ or $-1$ to even $n$. The answer depends on whether the greatest power of $2$ that divides $n$ is $2$, $2^2$, or $2^w$ where $w\ge 3$. This is because the number of solutions of $x^2\equiv 1 \pmod{2^k}$ is $1$ when $k=1$, $2$ when $k=2$, and $4$ when $k\ge 3$.