Prove two numbers are coprime

By definition $$a_1=\sum_{n=1}^{p-1}(\prod_{m\ne n}m).$$ So in fact $a_1$ and $(p-1)!$ need not be co-prime (for $p=7$, we have $a_1=1764$ and $(p-1)!$ is even). The proof in the linked question only requires that $p$ does not divide $(p-1)!$, which is clear: $(p-1)!$ is divisible only by primes $<p$.

P.S. In case you are wondering why the proof only requires that $p$ does not divide $(p-1)!$, notice that we can reduce the fraction $\frac{a_1}{(p-1)!}$ to the lowest terms $\frac ab$, where $a=\frac{a_1}{\gcd(a_1,(p-1)!)}$. Since $p$ does not divide $(p-1)!$, $\frac{a_1}{\gcd(a_1,(p-1)!)}$is divisible by $p^2$, hence concluding the proof.


Hope this helps.


It is not neceassary to have $\text{gcd}(a_1,(p-1)!)= 1$. From Vieta's formula, in $f(x)$, coeff. of $x$ is sum of all products of $(p-2)$ roots of $f(x)$ choosen at a time. $$a_1=2\cdot3\cdots(p-1)+1\cdot 3\cdot \cdots(p-1)+\cdots +1\cdot 2\cdots (p-2)\\ =(p-1)!\big(1+\frac{1}{2}+\frac13+\cdots + \frac1{p-1}\big) $$

hence, the required sum is equal to $$\frac{a_1}{(p-1)!}$$ If some common factors between $a_1$ and $(p-1)!$ cancels out, then also $p^2|a_1$, as all terms of $a_1$ contains products of numbers below $p$.