Sub topic 5
Primes and Composites
This chapter assumes you can work with integers (including negatives and zero), read exponent notation such as 2^3, and carry out long division. It builds on the definitions of factor, multiple, and divisibility from the previous chapters. The next chapter uses primes to build the prime factorization.
What counts as prime
A prime number is an integer greater than 1 whose only positive factors are 1 and itself. A composite number is an integer greater than 1 that has at least one positive factor besides 1 and itself. Every integer greater than 1 is exactly one of the two.
The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47. Know this list by heart. The GRE expects you to recognize them quickly.
Three edge cases cause most of the errors:
- 1 is neither prime nor composite. It has only one positive factor, so it fails the definition of prime. It also has no factor other than 1 and itself, so it is not composite.
- 0 and negative integers are neither prime nor composite. On the GRE, the words "prime" and "composite" apply only to integers greater than 1. So "-3 is prime" is false.
- 2 is the only even prime. Every other even integer greater than 2 is divisible by 2, so it has a third factor.
Testing whether a number is prime
To decide whether n is prime, you only need to test primes up to the square root of n. The reason: if n = a × b with both a and b greater than the square root of n, then a × b would be greater than n. So any composite number has a factor no larger than its square root, and it also has a prime factor no larger than that.
Take 91. Its square root is a little over 9, since 9² = 81 and 10² = 100. Test the primes 2, 3, 5, and 7.
- 91 is odd, so 2 does not divide it.
- The digit sum is 9 + 1 = 10, which is not a multiple of 3.
- It does not end in 0 or 5.
- 7 × 13 = 91, so 7 divides it.
So 91 is composite. It is a classic trap, because it looks prime.
Take 97. Its square root is a little under 10, so you test 2, 3, 5, and 7. None divides 97, so 97 is prime.
For the GRE, the useful cutoffs are small. To check any number below 121, test only 2, 3, 5, and 7. To check any number below 169, add 11.
The following Python function applies the same rule.
def is_prime(n):
if n < 2:
return False
p = 2
while p * p <= n:
if n % p == 0:
return False
p += 1
return True
print([n for n in range(1, 50) if is_prime(n)])
# [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
print(is_prime(91), is_prime(97)) # False TrueThe loop stops when p * p exceeds n. That is the square-root rule written in code.
Where primes sit
Apart from 2 and 3, every prime is one more or one less than a multiple of 6. The reason is that any integer has the form 6k, 6k + 1, 6k + 2, 6k + 3, 6k + 4, or 6k + 5. The forms 6k, 6k + 2, and 6k + 4 are even. The form 6k + 3 is divisible by 3. That leaves 6k + 1 and 6k + 5, which is the same as 6k − 1.
The statement runs in one direction only. Every prime above 3 has the form 6k ± 1, but not every number of that form is prime. For example, 25 = 6 × 4 + 1 and 35 = 6 × 6 − 1 are both composite.
The table shows how the primes up to 50 distribute across ranges.
| Range | Primes | Count |
|---|---|---|
| 1 to 10 | 2, 3, 5, 7 | 4 |
| 11 to 20 | 11, 13, 17, 19 | 4 |
| 21 to 30 | 23, 29 | 2 |
| 31 to 40 | 31, 37 | 2 |
| 41 to 50 | 41, 43, 47 | 3 |
There are infinitely many primes, but they thin out as numbers grow. The GRE never asks you to list large primes. It asks you to reason about their properties.
Properties you can use
These facts come up repeatedly.
- The product of two or more integers greater than 1 is composite. For example, 3 × 7 = 21 has the extra factors 3 and 7.
- A prime has exactly two positive factors. This links to factor counting later, where a prime p gives the count (1 + 1) = 2.
- Two different primes share no factor other than 1. Their GCD is 1, and their LCM is their product. Numbers whose GCD is 1 are called relatively prime or coprime. Two numbers can be coprime without either being prime. For example, 8 and 15 are coprime.
- If a prime p divides a product ab, then p divides a or p divides b (or both). This fails for composites. For example, 6 divides 4 × 3 = 12, but 6 divides neither 4 nor 3.
- Consecutive integers are always coprime. Any common factor would have to divide their difference, which is 1.
- The sum of two primes is even unless one of them is 2. Two odd primes add to an even number. So if p and q are primes and p + q is odd, one of them must be 2.
- Only 2 and 3 are consecutive primes. Any other two consecutive integers include an even number greater than 2, which is composite.
Common GRE patterns
Pattern 1: "How many primes are there between…" List them with the divisibility rules. Cross out evens, then multiples of 3, 5, and 7. For 20 to 40, the survivors are 23, 29, 31, and 37, so the count is 4.
Pattern 2: A prime with a given property. Suppose p is a prime and p² is divisible by 12. Since p is prime, p² has only the prime factor p. But 12 = 2² × 3 needs both 2 and 3. A single prime cannot supply both, so no such p exists. This reasoning, that the only prime factor of p^k is p, is the core of prime questions.
Pattern 3: Quantitative comparison with primes. Consider this question.
- Quantity A: the smallest prime greater than 20
- Quantity B: the number of positive factors of 36
The smallest prime greater than 20 is 23, because 21 = 3 × 7 and 22 = 2 × 11. The number 36 = 2² × 3² has (2 + 1)(2 + 1) = 9 factors. Quantity A is greater.
Pattern 4: Hidden composites. Watch for numbers that look prime but are not. These appear often: 51 = 3 × 17, 57 = 3 × 19, 87 = 3 × 29, 91 = 7 × 13, 119 = 7 × 17, and 143 = 11 × 13. A quick digit-sum check catches most of them.
Why the order of testing matters
Test in this order, from cheapest to most expensive:
- Is the number even? (Then it is composite unless it is 2.)
- Does it end in 5? (Then it is composite unless it is 5.)
- Is its digit sum a multiple of 3?
- Divide by 7.
- Divide by 11 and 13 if the number is above 120.
The diagram shows this as a decision path.
Mistakes to avoid
- Calling 1 prime. It is not.
- Calling 2 "not prime because it is even." It is prime, and it is the only even prime.
- Assuming an odd number is prime. 9, 15, 21, 25, 27, 33, 35, 39, 45, 49, and 51 are odd composites.
- Treating "p is prime" as "p is odd." This breaks when p = 2.
- Using a negative integer as a prime or a composite.
- Testing divisors past the square root. This wastes time but does not give wrong answers. Stopping too early does give wrong answers.
Practice
Exercise
Is 119 prime or composite? Show the test you used.
Show answer
Its square root is a little under 11 (since 11² = 121), so test 2, 3, 5, and 7. 119 is odd, its digit sum is 11 (not a multiple of 3), and it does not end in 0 or 5. Dividing by 7 gives 7 × 17 = 119. So 119 is composite.
Exercise
If p and q are primes and p + q = 15, what is p × q?
Show answer
The sum is odd, so one prime must be 2 (two odd primes would give an even sum). Then the other is 13, which is prime. So p × q = 2 × 13 = 26.
Exercise
Quantity A is the number of primes between 40 and 60. Quantity B is 5. Which quantity is greater, or are they equal?
Show answer
The primes between 40 and 60 are 41, 43, 47, 53, and 59, which gives 5. The quantities are equal.