Number theory: divisors, gcd and modular arithmetic
Factor integers, count divisors and reduce large arithmetic expressions with remainders.
Core concepts and method
Prime factorisation separates an integer into prime powers. If n=pᵃqᵇ, each divisor chooses an exponent from 0 to a and 0 to b independently; there are (a+1)(b+1) positive divisors.
The Euclidean algorithm replaces (a,b) with (b,a mod b) until the remainder is zero. The last nonzero remainder is gcd(a,b); for positive integers, lcm(a,b)=ab/gcd(a,b).
Modular arithmetic lets you reduce each addition or multiplication modulo m. For powers, follow the remainders or use repeated squaring instead of constructing enormous integers.
Worked example
Find the number of positive divisors of 360 and compute gcd(360,84).
- Factor 360=2³×3²×5. Count possible exponents: 4×3×2=24 divisors.
- 360 mod 84=24; 84 mod 24=12; 24 mod 12=0. The gcd is 12.
- Check that 12 divides both numbers. Their lcm is 360×84/12=2520; the gcd×lcm identity holds.
Try it yourself
How many positive divisors does 72 have? What is 7⁵ modulo 10?
Show a hint
72=2³×3²; follow the last digits of successive powers of 7.
Check your reasoning
72 has (3+1)(2+1)=12 divisors. The cycle 7,9,3,1 repeats every 4, so 7⁵ ends in 7.
Practice the technique
These competition questions use related mathematical ideas. You can check your answers as a guest; sign in to save your progress.
- Twelve-divisor sevens · easy · 25 min
- GCD checksum · easy · 25 min
- Twisted power checksum · easy · 25 min
- Last-digit cycle · easy · 5 min
About the editorial approach · Report a mistake in this lesson