If $n\mid a^2-1$, $n$ an odd integer, show $n = \gcd(a-1, n)\gcd(a+1, n)$ Hi I'm practicing some number theory and I've come across the following problem,
Suppose $n \geq 1$ is an odd integer that divides $a^2 - 1$ for some integer $a > 1$. Prove that,
$$n = \gcd(a-1, n)\gcd(a+1, n)$$
Now I know that the $\gcd(a-1, a+1) = 1$ if $a$ is even and $2$ if $a$ is odd and I believe this is relevant but I can't solve the problem. I've not really any idea where to start so even just help with that would be great.
Thanks
 A: $(a\!-\!1,n)(a\!+\!1,n) = (a^2\!-\!1,\,n(\underbrace{a\!-\!1,a\!+\!1,n}_{\textstyle{(a-1,\underbrace{2,n)}_{\large 1}}})) = (a^2\!-\!1,n) \,\ [= n\ $ by hypothesis]
Remark $\ $ The above proves that $\ (b,n)(c,n) = (bc,n)\ $ if $\ (b,c,n) = 1,\ $ using only basic universal gcd laws (associative,distributive,etc), so it works very generally.
A: We will prove the result by showing that (i) $n$ divides $\gcd(a-1,n)\gcd(a+1,n)$ and (ii)  $\gcd(a-1,n)\gcd(a+1,n)$ divides $n$.
Proof of (i): Let $b=\gcd(a-1,n)$.  Then $b$ divides $n$. Let $n=bq$.  
We know that $bq$ divides $(a-1)(a+1)$, so $q$ divides $(a-1)(a+1)$.  But $q$ and $a-1$ are relatively prime. It follows that $q$ divides $a+1$. Thus $q$ divides $\gcd(a+1,n)$.  It follows that 
$n$ divides $\gcd(a-1,n)\gcd(a+1,n)$. 
Proof of (ii): Note that $\gcd(a-1,n)$ and $\gcd(a+1,n)$ are relatively prime. This is because any common divisor $k\gt 0$ of $\gcd(a-1,n)$ and $\gcd(a+1,n)$ must divide $n$, $a-1$, and $a+1$. So $k$ divides $(a+1)-(a-1)$. But $k$ divides $2$. Since $n$ is odd, that means $k=1$.   Since $\gcd(a-1,n)$ and $\gcd(a+1,n)$ each divide $n$, and are relatively prime, their product divides $n$. This completes the proof.  
A: You know $n$ is odd, so essentially this $2$ is not supposed to give you a problem. You know that $n \, | \, a^2 - 1$, hence $n \, | \, (a-1)(a+1)$. By the fundamental theorem of arithmetic, we can write $n$ as a product of distinct prime powers. 
Suppose $p^{\alpha} \, || \, (a-1)(a+1)$ and $p \neq 2$ is a prime. Since $p \not\mid (a-1,a+1) \in \{1,2\}$, we know that $p$ cannot divide both $(a-1)$ and $(a+1)$. It follows that $p^{\alpha} | a-1$ or $p^{\alpha} | a+1$. 
Since the formula you are trying to prove is multiplicative on both sides for 
integers $n$, you can restrict the proof to the prime power case. I let you fill in the blanks.
Hope that helps, 
A: First we shall need
\begin{align}
(a-1, a+1)&\overset{a=2k}{=}(2k-1, 2k+1)=1\tag{1}\\
(a-1, a+1)&\overset{a=2k+1}{=}(2k, 2k+2)=2(k, k+1)=2\tag{2}
\end{align}
We have $n\mid a^2-1=(a-1)(a+1)$, where $n$ is odd.
Now if $a$ is even $(a-1,a+1)=1$ by $(1)$. Hence in this case $n\mid(a-1)$ and $n\nmid(a+1)$, or vice-versa. In the first case $(a-1, n)=n$, $(a+1, n)=1$, and in the second $(a-1, n)=1$, $(a+1, n)=n$. Multiplying proves the theorem.
If $a$ is odd $(a-1, a+1)=2$ by $(1)$, but since $n$ is odd, $(2,n)=1$, and so the proof reverts to the $a$ even case. 
