Maths WorkshopMaths problems with full solutions
Exercise 1330Number theory › CongruencesOlympiadAdded 5 Nov 2026

If aᵖ ≡ bᵖ (mod p) then aᵖ ≡ bᵖ (mod p²)

#Fermat's little theorem#binomial theorem#lifting

Statement

Let pp be a prime and a,ba,b integers with ap≡bp(modp)a^p\equiv b^p\pmod p. Prove that ap≡bp(modp2)a^p\equiv b^p\pmod{p^2}.

Hint

By Fermat's little theorem a≡b(modp)a\equiv b\pmod p. Write a=b+kpa=b+kp and expand (b+kp)p(b+kp)^p.

Show solutionHide solution

Solution

Step 1. By Fermat's little theorem ap≡aa^p\equiv a and bp≡b(modp)b^p\equiv b\pmod p. The hypothesis gives a≡b(modp)a\equiv b\pmod p, so a=b+kpa=b+kp for some integer kk.

Step 2: binomial expansion.
ap=(b+kp)p=bp+(p1)bp−1kp+∑j≥2(pj)bp−j(kp)j.a^p=(b+kp)^p=b^p+\binom p1b^{p-1}kp+\sum_{j\ge2}\binom pjb^{p-j}(kp)^j.
The second term is p⋅bp−1⋅kpp\cdot b^{p-1}\cdot kp, a multiple of p2p^2. For j≥2j\ge2 the factor (kp)j(kp)^j is a multiple of p2p^2. Hence ap≡bp(modp2)a^p\equiv b^p\pmod{p^2}.

Example. 17≡2(mod5)17\equiv2\pmod5, and indeed 175−25=1419825=25⋅5679317^5-2^5=1419825=25\cdot56793.

Remark. First step of "lifting the exponent": vp(ap−bp)=vp(a−b)+1v_p(a^p-b^p)=v_p(a-b)+1 when p∣a−bp\mid a-b and pp is odd.

Lesson. When two numbers are congruent modulo pp, write one as the other plus a multiple of pp; the binomial expansion then shows the pp-th powers agree one power of pp higher.