Interview math is a small toolbox applied to disguised problems.
Think number theory when you see:
- Divisibility, remainders, “mod 10^9+7”
- Counting pairs/triplets with huge n → formula or precompute
- Powers that overflow → fast power
- “How many ways” → combinatorics
Quick Recognition Cheat Sheet
| If you see… | Think… |
|---|---|
| Divisor / multiple / coprime | GCD (Euclid) |
| Primes up to n / prime checks | Sieve of Eratosthenes |
| Answer mod 10^9+7 | Modular arithmetic |
| Huge exponent / repeated multiply | Fast power |
| ”Number of ways to choose” | Combinatorics (nCr) |
| Points, lines, turns | Cross product |
Pattern Table
| Pattern | Typical Questions | Trigger |
|---|---|---|
| GCD / LCM | Water jug, fraction simplify | Divisibility language |
| Prime sieve | Count primes ≤ n | Many primality queries |
| Modular arithmetic | Big results mod p | Overflow risk |
| Fast power | pow(x, n), matrix power | Exponent too big to loop |
| Combinatorics | Unique paths, count sequences | ”How many ways” |
Mental Trigger
Overflow or huge loop? → math trick exists. Find it before coding brute force.
Decision Guide
Divisibility question
↓
GCD via Euclid
Many primality questions
↓
Sieve once, answer O(1)
Result too big / mod required
↓
Modular rules + fast power + inverse
"How many ways"
↓
nCr via Pascal or factorialsPremium Content
Unlock Math Patterns and all premium lessons with a subscription.
All premium lessons
Ad-free experience
Priority support
From ₹199.99/year — See plans