Prime Number Checker

Prime or composite, with the divisibility test worked out step by step
Is 29 prime?
Is 51 prime or composite?
Is 223 prime?
Prime factors of 113

Prime, Composite, and Why 1 Is Neither

A prime number is a whole number greater than 1 with exactly two distinct divisors: 1 and itself. A composite number has more than two. So 7 is prime (only 1×71 \times 7), while 9 is composite (1×91 \times 9 and 3×33 \times 3).

1 is not prime. It has only one divisor, not two. That is not a technicality invented to annoy students: if 1 counted as prime, every number would have endlessly many prime factorisations (6=2×3=1×2×3=1×1×2×36 = 2 \times 3 = 1 \times 2 \times 3 = 1 \times 1 \times 2 \times 3), and the guarantee that each number factors into primes in exactly one way would collapse.

2 is prime — and it is the only even prime, because every other even number has 2 as a third divisor. Students often expect 2 to be the exception in the other direction; it is not.

The first primes are 2,3,5,7,11,13,17,19,23,29,31,37,41,43,472, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47.

The Test: Divide by Primes up to √n

To check whether nn is prime, try dividing by each prime from 2 upward, and stop once the prime exceeds n\sqrt{n}.

Why stop there? If n=a×bn = a \times b with both factors above n\sqrt{n}, then a×b>na \times b > n — impossible. So any composite number must have a factor at or below its square root. For n=97n = 97, 979.85\sqrt{97} \approx 9.85, so testing 2, 3, 5 and 7 settles it completely.

The divisibility shortcuts make this fast without a calculator:

DivisorTest
2last digit is even
3digit sum is a multiple of 3
5last digit is 0 or 5
7double the last digit, subtract from the rest
11alternating digit sum is a multiple of 11

One clean division with no remainder is enough to declare the number composite — you can stop immediately.

Numbers That Trick People

  • 51 looks prime but 5+1=65 + 1 = 6 is a multiple of 3, so 51=3×1751 = 3 \times 17.
  • 91 slips past the 2, 3 and 5 tests, then fails at 7: 91=7×1391 = 7 \times 13.
  • 361 is 19219^2, so it is composite even though nothing small divides it. Always test all the way to n\sqrt{n} before declaring a number prime.
  • 9 is not prime. Odd does not mean prime; 9=3×39 = 3 \times 3.
  • Stopping too early. Checking only 2, 3 and 5 on a three-digit number proves nothing. For n=223n = 223 you must reach 13, since 22314.9\sqrt{223} \approx 14.9.
  • Confusing this with prime factorisation. "Is 113 prime?" asks for yes or no; "prime factors of 113" asks for the full breakdown — which here is just 113113 itself, because 113 is prime.

Examples

Step 1: 295.39\sqrt{29} \approx 5.39, so it is enough to test the primes 2, 3 and 5.
Step 2: 2: 29 is odd, so not divisible by 2.
Step 3: 3: digit sum 2+9=112 + 9 = 11, which is not a multiple of 3.
Step 4: 5: 29 does not end in 0 or 5.
Step 5: No prime up to 29\sqrt{29} divides it, so the search is over.
Answer: 29 is prime

Step 1: 517.14\sqrt{51} \approx 7.14, so test 2, 3, 5 and 7.
Step 2: 2: 51 is odd — no.
Step 3: 3: digit sum 5+1=65 + 1 = 6, which is a multiple of 3 — yes.
Step 4: Divide: 51÷3=1751 \div 3 = 17, so 51=3×1751 = 3 \times 17.
Step 5: A third divisor exists, so the test stops here.
Answer: 51 is composite: 51=3×1751 = 3 \times 17

Step 1: 22314.93\sqrt{223} \approx 14.93, so test the primes 2, 3, 5, 7, 11 and 13.
Step 2: 2: 223 is odd. 3: digit sum 2+2+3=72 + 2 + 3 = 7, not a multiple of 3. 5: does not end in 0 or 5.
Step 3: 7: 7×31=2177 \times 31 = 217 and 223217=6223 - 217 = 6, so there is a remainder.
Step 4: 11: 11×20=22011 \times 20 = 220, remainder 3.
Step 5: 13: 13×17=22113 \times 17 = 221, remainder 2.
Step 6: Every prime up to 14.93 has been tried and none divides 223.
Answer: 223 is prime

Frequently Asked Questions

No. A prime must have exactly two distinct divisors, and 1 has only one. Excluding it is what makes prime factorisation unique — otherwise you could pad any factorisation with as many 1s as you liked.

Yes, and it is the only even prime. Every other even number is divisible by 1, itself and 2, which gives it at least three divisors. So 2 is prime and 4, 6, 8 and every larger even number is composite.

Only up to the square root of the number, and only by primes. If a number had two factors both larger than its square root, their product would exceed the number itself, so a composite number always has a factor at or below the square root.

No. 9 equals 3 times 3, so it has three divisors: 1, 3 and 9. Being odd is not the same as being prime — 9, 15, 21, 25, 27 and 33 are all odd composites.

Related Solvers

Try AI-Math for Free

Get step-by-step solutions to any math problem. Upload a photo or type your question.

Start Solving