Given $a,\,b\in\mathbb{Z}$ relatively primes and $\,n \gt 0$, $n\in\mathbb{Z}$, calculate a) $\gcd(a+nb,a+(n+1)b)$; b) $\gcd(a+nb,a+(n+2)b)$. I was able to solve part a), proving by Mathematical Induction on $\,n\,$ that $\,\gcd(a+nb,a+(n+1)b) = 1$. (I can supply my solution if of interest).

However, I did'nt succeeded in tackling part b). Clearly, $\,n\,$ and $\,n+2\,$ always have the same parity, but noting this wasn't enough for me to find a solution. On the other side, I have performed a few numerical experiments that led me to suspect $\,\gcd(a+nb,a+(n+2)b)\,$ is equal to


1 if $\,a\,$ is odd and $\,b\,$ is even, with any $\,n &gt; 0$;
1 is $\,a\,$ is even and $\,b\,$ is odd, with $\,n\,$ odd;
2 if $\,a\,$ is even and $\,b\,$ is odd, with $\,n\,$ even;
1 is $\,a\,$ is odd and $\,b\,$ is odd, with $\,n\,$ even;
2 is $\,a\,$ is odd and $\,b\,$ is odd, with $\,n\,$ odd;


I would appreciate any help in proving or disproving this conjecture.
$$\gcd(a+nb,a+(n+2)b)= \gcd(a+nb,2b).$$ Since $b$ is coprime to $a$ it is also coprime to $a+nb$ and therefore $$\gcd(a+nb,2b)= \gcd(a+nb,2).$$ The required gcd is therefore $1$ if $a+nb$ is odd and $2$ if $a+nb$ is even.
If $p$ is a prime which divides $a+nb$ and $a+(n+1)b$, it divides $a+(n+1)b-(a+nb)=b$, it divides $nb$ and $(a+nb)-nb=a$ contradiction since $gcd(a,b)=1$. We deduce that $gcd(a+nb, a+(n+1)b)=1$.

If $p$ divides $a+nb$ and $a+(n+2)b$, $p$ divides $a+(n+2)b-(a+nb)=2b$.

If $p$ is odd, $p$ divides $b$, $nb$ and $a+nb-nb=a$ contradiction. If $p=2$

$a+(n+2)b=a+nb+2b$ thus $a+nb$ is even, since $a$ and $b$ are odd, $nb$ is odd and $n$ is odd.

Thus if $n$ is odd $gcd(a+nb,a+(n+2)b)=2$ if it is even it is $1$.