TITLE: 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)$.
QUESTION [2 upvotes]: 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 > 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.

REPLY [2 votes]: $$\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.
{"set_name": "stack_exchange", "score": 2, "question_id": 3339402}