Let be a (positive) common divider of and of . You wrote , so divides both the left-hand side and the first term on the right side, which implies that as well.

Suppose does not divide . Then and are relatively prime (using the fact that is prime), so that . Remembering that , we deduce . So and . However, and are relatively prime, so that and are relatively prime as well, and their only positive common divider is 1. So .

Suppose now that divides . Then, letting , we have and , so . Again, because , we get , so that .

We have shown that the only common dividers of and are either or . This implies that is either 1 or 2.

This was a nice problem, thank you

Laurent.