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

Halving in modular arithmetic

#halving#modular arithmetic#odd modulus

Statement

In Z/nZ\mathbb{Z}/n\mathbb{Z} with nn odd, show that the congruence 2x≡a(modn)2x\equiv a\pmod n has a unique solution for every aa.

Hint

22 is invertible mod nn iff nn is odd.

Show solutionHide solution

Solution

Inverse of 2. nn odd means gcd⁡(2,n)=1\gcd(2,n)=1, so 22 is invertible mod nn. The inverse is (n+1)/2(n+1)/2 (since 2⋅(n+1)/2=n+1≡12\cdot(n+1)/2=n+1\equiv1).

Solution. x≡a⋅(n+1)/2(modn)x\equiv a\cdot(n+1)/2\pmod n.

Conclusion. Halving is well defined mod nn when nn is odd; it is not when nn is even.