Maths WorkshopMaths problems with full solutions
Exercise 841Number theory › CongruencesL1Added 3 Nov 2026

Coprimality via congruences

#coprime#congruence#linear combination

Statement

Show that gcd⁡(a,n)=1\gcd(a,n)=1 iff the congruence ax≡1(modn)ax\equiv1\pmod n has a solution.

Hint

ax≡1(modn)ax\equiv1\pmod n iff n∣ax−1n\mid ax-1, iff ax−1=knax-1=kn, iff ax−kn=1ax-kn=1, iff Bézout.

Show solutionHide solution

Solution

Forward. If gcd⁡(a,n)=1\gcd(a,n)=1, Bézout gives au+nv=1au+nv=1, so au≡1(modn)au\equiv1\pmod n: x=ux=u is a solution.

Converse. If ax≡1(modn)ax\equiv1\pmod n, then ax−1=knax-1=kn for some kk, so ax−kn=1ax-kn=1. Any common divisor of a,na,n divides 11, so gcd⁡(a,n)=1\gcd(a,n)=1.

Conclusion. aa is invertible mod nn iff gcd⁡(a,n)=1\gcd(a,n)=1.