Maths WorkshopMaths problems with full solutions
Exercise 542Number theory › PrimesHigh schoolAdded 3 Nov 2026

Coprimality with primes

#coprime#prime#divisibility

Statement

Show that for a prime pp and integer aa: either p∣ap\mid a or gcd⁡(a,p)=1\gcd(a,p)=1.

Hint

The only positive divisors of pp are 11 and pp.

Show solutionHide solution

Solution

Divisors. d=gcd⁡(a,p)d=\gcd(a,p) divides pp, so d∈{1,p}d\in\{1,p\}.

Case d=1d=1. gcd⁡(a,p)=1\gcd(a,p)=1.

Case d=pd=p. p∣ap\mid a.

Conclusion. Either p∣ap\mid a or gcd⁡(a,p)=1\gcd(a,p)=1 (mutually exclusive).

Corollary. For pp prime and a≢0(modp)a\not\equiv0\pmod p, aa is invertible mod pp.