Mathwords logoMathwords

Prime and Composite Numbers — Definition, Formula & Examples

Prime numbers are whole numbers greater than 1 that have exactly two factors: 1 and themselves. Composite numbers are whole numbers greater than 1 that have more than two factors.

A natural number p>1p > 1 is prime if its only positive divisors are 1 and pp. A natural number n>1n > 1 is composite if there exists a natural number dd such that 1<d<n1 < d < n and dd divides nn evenly. The number 1 is neither prime nor composite.

How It Works

To decide whether a number is prime or composite, try dividing it by every whole number starting from 2 up to the number itself. If any of those divisions come out even (no remainder), the number is composite. If none of them divide evenly, the number is prime. A useful shortcut: you only need to test divisors up to the square root of the number, because any factor larger than the square root pairs with a factor smaller than it. For example, to test 29, you only check 2, 3, 4, and 5 (since 52=25<295^2 = 25 < 29 but 62=36>296^2 = 36 > 29). None divide 29 evenly, so 29 is prime.

Worked Example

Problem: Classify each number as prime, composite, or neither: 1, 2, 9, 13, 24.
Check 1: The number 1 has only one factor (itself). By definition, it is neither prime nor composite.
Check 2: The factors of 2 are just 1 and 2. That is exactly two factors, so 2 is prime. It is also the only even prime number.
Check 9: Divide 9 by numbers starting from 2. Since 9 ÷ 3 = 3 with no remainder, 9 has a factor other than 1 and itself.
9=3×39 = 3 \times 3
Check 13: Test divisors 2, 3 (since the square root of 13 is about 3.6). Neither 2 nor 3 divides 13 evenly, so 13 is prime.
Check 24: 24 is even, so 2 divides it. That immediately makes 24 composite.
24=2×12=2×2×6=2×2×2×324 = 2 \times 12 = 2 \times 2 \times 6 = 2 \times 2 \times 2 \times 3
Answer: 1 is neither; 2 and 13 are prime; 9 and 24 are composite.

Another Example

Problem: Is 51 prime or composite?
Find the testing range: The square root of 51 is about 7.1, so test divisors 2, 3, 4, 5, 6, and 7.
Test 2: 51 is odd, so 2 does not divide it.
Test 3: Add the digits: 5 + 1 = 6, which is divisible by 3. So 3 divides 51.
51÷3=1751 \div 3 = 17
Answer: 51 is composite because 51=3×1751 = 3 \times 17.

Visualization

Why It Matters

Understanding prime and composite numbers is essential in 4th–6th grade math, where you use them to find greatest common factors and least common multiples. In computer science, large prime numbers form the backbone of encryption that secures online banking and messaging. Building a strong sense of primes also prepares you for algebra and number theory in later courses.

Common Mistakes

Mistake: Calling 1 a prime number.
Correction: 1 has only one factor, not two. Prime numbers must have exactly two distinct factors, so 1 is neither prime nor composite.
Mistake: Assuming all odd numbers are prime.
Correction: Many odd numbers are composite. For example, 9 = 3 × 3, 15 = 3 × 5, and 21 = 3 × 7. Always check for factors before deciding.

Related Terms