Introduction
Classifying numbers as even, odd, prime, or composite is fundamental to number theory and aptitude problems. These categories help in pattern recognition, divisibility shortcuts, and building techniques for more advanced problems like factorization and modular arithmetic.
Pattern: Even, Odd, Prime, Composite
Pattern
Use simple divisibility and divisor-count rules to classify integers quickly.
- Even: An integer n is even if
n ≡ 0 (mod 2). In practice: last digit ∈ {0,2,4,6,8}. - Odd: An integer n is odd if
n ≡ 1 (mod 2). Last digit ∈ {1,3,5,7,9}. - Prime: An integer p > 1 is prime if its only positive divisors are 1 and p. Practical test: check divisibility by all primes ≤ √p.
- Composite: An integer n > 1 that has a divisor d with 1 < d < n (i.e., more than two positive divisors).
- Special note: 1 is neither prime nor composite.
- Quick primality shortcuts:
- If n is even and n > 2 → composite.
- If sum of digits divisible by 3 (and n > 3) → composite.
- If last digit 0 or 5 (and n > 5) → composite.
- Only candidates for primes > 3 are of form
6k ± 1(useful to skip checks), but still test divisibility up to √n. - Sieve of Eratosthenes: efficient way to list primes up to N (cross out multiples of found primes).
- Formal primality test (practical): To test n: check divisibility by 2, 3, then all primes 5, 7, 11, ... up to ⌊√n⌋. If none divide n → prime; else composite.
Step-by-Step Example
Question
Classify the numbers 1, 2, 29, and 49 as even/odd and prime/composite.
Solution
-
Step 1: Number: 1
Check: 1 <= 1, it has exactly one positive divisor (1). By definition, 1 is neither prime nor composite. It is odd (last digit 1), but categorized as "neither" for prime/composite classification.
-
Step 2: Number: 2
Check even/odd: last digit 2 → even.
Prime test: 2 > 1 and its divisors are 1 and 2 only → prime (smallest and only even prime).
-
Step 3: Number: 29
Check even/odd: last digit 9 → odd.
Prime test (practical): √29 ≈ 5.38 → test primes ≤ 5 → {2,3,5}.
- 29 mod 2 = 1 (not divisible)
- 29 mod 3 = 2 (not divisible)
- 29 mod 5 = 4 (not divisible)
No divisors found → 29 is prime.
-
Step 4: Number: 49
Check even/odd: last digit 9 → odd.
Prime test: √49 = 7 → test primes ≤ 7 → {2,3,5,7}.
- 49 mod 2 = 1
- 49 mod 3 = 1
- 49 mod 5 = 4
- 49 mod 7 = 0 → divisible by 7
Found divisor 7 (1 < 7 < 49) → 49 is composite (49 = 7 × 7).
-
Final Answer
1 → neither prime nor composite (odd);
2 → even & prime;
29 → odd & prime;
49 → odd & composite. -
Quick Check
Verify divisions used above: 29 has no small prime divisors (2,3,5). 49 ÷ 7 = 7 confirms composite. 2 ÷ 2 = 1 confirms prime. 1 is special-case by definition. ✅
Quick Variations
1. Identify prime pairs (twin primes) like (11,13), (17,19).
2. Determine if a large odd number is prime using trial division up to √n or probabilistic tests for very large n.
3. Factor small composites by checking primes ≤ √n.
Trick to Always Use
- Step 1 → Check last digit for even/odd quickly.
- Step 2 → Eliminate composites fast: test 2, 3, 5 using last digit and digit-sum rules.
- Step 3 → For primality, only test divisors up to √n (and only prime divisors for efficiency).
- Step 4 → Use the 6k ± 1 filter to skip obvious non-candidates when testing primes > 3.
Summary
Summary
- Even/odd classification is determined directly from the last digit.
- Prime/composite classification depends on divisor checks: a prime has exactly two divisors (1 and itself), while composites have more.
- 1 is a special case - it is neither prime nor composite.
- 2 is the only even prime; all other even numbers greater than 2 are composite.
Example to remember:
Check last digit first for even/odd. For prime testing, check divisibility by 2, 3, 5, and then primes up to √n. If none divide, the number is prime.
