<s>[INST] Analytic Proof of Wilson's Theorem I'm trying to find a reference for the following (analytic) proof of Wilson's Theorem. I would appreciate it immensely if some of you knew and told me the person who first came up with it. Here is the proof:
We start by considering the Maclaurin series of the function $f(x)=\ln \left( \frac{1}{1-x} \right)$, that is,
$\displaystyle \ln \left( \frac{1}{1-x} \right)= \sum_{n=1}^{\infty} \frac{x^n}{n} \tag*{}$
for $x \in [-1, 1).$
By simply using the definition of $\ln$ on the equation above, we get
$\displaystyle e^{x+\frac{x^2}{2}+\frac{x^3}{3}+ \cdots}=\frac{1}{1-x}=1+x+x^{2}+ \cdots + x^{p} + \cdots \tag{1}$
We can then rewrite the leftmost side of $(1)$ as
$\displaystyle \begin{align} e^{x+\frac{x^2}{2}+\frac{x^3}{3}+…} & = e^{x}e^{\frac{x^2}{2}}e^{\frac{x^3}{3}} \cdots \\ & = \prod_{n=1}^{\infty} e^{\frac{x^n}{n}} \\ & = \prod_{n=1}^{\infty} \sum_{k=0}^{\infty} \frac{\left( \frac{x^n}{n} \right)^k}{k!} \\ & = \left( 1+\frac{x}{1!}+\frac{x^2}{2!}+ \cdots \right) \cdot \left( 1+\frac{x^{2}/2}{1!}+\frac{(x^{2}/2)^2}{2!} + \cdots \right) \cdots \left(1+\frac{x^{p}/p}{1!}+\frac{(x^{p}/p)^2}{2!}+ \cdots \right) \cdots \\ & = 1+\frac{x}{1!}+x^{2} \left( \frac{1}{2!} + \frac{1}{2}\right)+x^{3} \left( \frac{1}{3!} + \frac{1}{1!} \frac{1/2}{1!} + \frac{1/3}{1!} \right) + \cdots + x^{p} \left( \frac{1}{p!} + \frac{1}{(p-2)!} \frac{1/2}{1!} + \cdots + \frac{1/p}{1!} \right)+ \cdots \end{align} \tag{2}$
Combining the rightmost sides of $(1)$ and $(2)$ together gives us
$\displaystyle 1+x+x^{2}+ x^{3}+ \cdots + x^{p} + \cdots= 1+\frac{x}{1!}+x^{2} \left( \frac{1}{2!} + \frac{1}{2}\right)+x^{3} \left( \frac{1}{3!} + \frac{1}{1!} \frac{1/2}{1!} + \frac{1/3}{1!} \right) + \cdots + x^{p} \left( \frac{1}{p!} + \frac{1}{(p-2)!} \frac{1/2}{1!} + \cdots + \frac{1/p}{1!} \right)+ \cdots , \tag{3}$
from which follows that the coefficient of $x^{p}$ on the RHS of $(3)$ is $1$. That is,
$\displaystyle \frac{1}{p!}+\frac{1}{(p-2)!} \frac{1/2}{1!}+ \cdots + \frac{1/p}{1!} = 1. \tag{4}$
Notice that such a coefficient is of the form $\frac{1}{p!}+\frac{r}{s}+\frac{1}{p}$, where $\frac{r}{s}$ is the sum of a finite number of rationals, none of which has the factor $p$ in its denominator. Therefore, if $\frac{r}{s}$ is irreducible, then $p$ doesn’t divide $s$. We then proceed by rewriting $(4)$ as
$\displaystyle \frac{1}{p!}+\frac{r}{s}+\frac{1}{p}=1. \tag*{}$
Equivalently,
$\displaystyle 1-\frac{r}{s}=\frac{1}{p!}+\frac{1}{p}=\frac{1+(p-1)!}{p!}, \tag*{}$
and
$\displaystyle (s-r) \cdot (p-1)! = \frac{s(1+(p-1)!)}{p}. \tag*{}$
Hence, $\frac{s(1+(p-1)!)}{p}$ is an integer. Moreover, since $p$ doesn’t divide $s$, $\frac{1+(p-1)!}{p}$ is also an integer. Equivalently, $(p-1)! \equiv -1 \text{ (mod } p)$, as desired.
 [/INST] Here is a related argument with power series.
For $|x| < 1$ there is an identity
$$
e^x = \prod_{n \geq 1} (1 - x^n)^{-\mu(n)/n}.
$$
This can also be viewed as an identity of formal power series, and checked by verifying that the logarithmic derivatives ($f \leadsto f'/f$) of both sides are the same and that they start with the same constant term.
If we remove each factor on the right side where $p \mid n$, we get a different identity:
$$
e^{x + x^p/p + \cdots + x^{p^k}/{p^k} + \cdots} = \prod_{\substack{n \geq 1\\ p\nmid n}} (1 - x^n)^{-\mu(n)/n}.
$$
Look at the coefficient of $x^p$ on both sides.  On the left side, it is the coefficient of $x^p$ in $e^xe^{x^p/p}$, which is $1/p! + 1/p = (1 + (p-1)!)/p!$. On the right side, the coefficients of $(1 - x^n)^{\pm 1/n}$ are rational with no $p$ in the denominator when $p \nmid n$, so all coefficients on the right are rational with no $p$ in the denominator. Thus $(1 + (p-1)!)/p!$ is rational with no $p$ in the denominator, which means $p \mid (1 + (p-1)!)$, so $(p-1)! \equiv -1 \bmod p$.
This argument can be found in books on $p$-adic analysis where $p$-adic integrality of all the coefficients of the Artin-Hasse exponential is discussed.
This is related to the identity
$$
\log\left(\frac{1}{1-x}\right)  = \sum_{n \geq 1} \frac{x^n}{n}
$$
by extracting from each $n$ the highest power of $p$ dividing it:
$$
\log\left(\frac{1}{1-x}\right)  = \sum_{\substack{n \geq 1\\ p \nmid n}} \frac{g(x^n)}{n}
$$
where $g(x) = \sum_{k \geq 0} x^{p^k}/p^k$, so
$$
g(x) = \sum_{\substack{n \geq 1}{p \nmid n}} \frac{\mu(n)}{n}\log\left(\frac{1}{1-x^n}\right).
$$
</s>