Brainteasers & Logic
Number Theory & Divisibility
Overview
Number theory puzzles test recognition of modular patterns. Powers of integers repeat modulo any fixed number โ the cycle is always short. Fermat's Little Theorem is the elegant reason: for prime p, a^(p-1) โก 1. This converts 'what is 2^{1000} mod 101?' into a trivial calculation. The Euclidean GCD algorithm is also directly tested โ practice it until it's automatic.
How to Recognize
- โ'What is the last digit of 7^{100}?'
- โ'Find the remainder when dividing X by Y'
- โGCD/LCM problems
- โPowers of numbers follow repeating cycles mod any fixed base
Step-by-Step Approach
- 1.Last digit = mod 10. Find the cycle: compute a^1, a^2, ... mod 10 until repeat.
- 2.Fermat's Little Theorem: a^(pโ1) โก 1 (mod p) for prime p, gcd(a,p)=1
- 3.GCD: Euclidean algorithm โ gcd(a,b) = gcd(b, a mod b)
- 4.For composite moduli: Euler's theorem: a^ฯ(n) โก 1 (mod n)
Key Formulas
Worked Examples
Problem
What is the last digit of 3^{47}?
Solution
Compute 3^n mod 10: 3^1=3, 3^2=9, 3^3=27โ7, 3^4=81โ1, 3^5=243โ3. Cycle repeats with period 4: (3, 9, 7, 1).
47 mod 4 = 3 (since 47 = 11ร4 + 3).
3rd element of cycle (3, 9, 7, 1) = 7.
Last digit of 3^{47} = 7.
Answer
7. Cycle for powers of 3 mod 10 has length 4: (3,9,7,1). Since , last digit = 7.
Common Mistakes
- !
Using Fermat when the modulus is not prime. Fermat requires prime p. For composite n, use Euler's theorem with ฯ(n).
- !
Off-by-one in cycle position when exponent mod period = 0. n mod 4 = 0 means use the FOURTH position of the cycle, not the first.
- !
LCM formula: lcm(a,b) = ab/gcd(a,b). Never compute LCM by brute force for large numbers.
Practice Problems
Click "Show Answer" to revealWhat is the last digit of 9^{999}?
What is 7^{52} mod 13?
What is the sum of all integers from 1 to 100 that are NOT multiples of 3 or 5?