Prime Number Checker
To test a specific integer, use the Prime Number Checker.
The same result can be verified manually by checking whether any possible divisor up to the square root divides the number evenly.
The prime test
A number is prime if it is greater than 1 and has exactly two positive divisors: 1 and itself.
To check whether a number is prime, you do not need to test every number below it. You only need to see whether any whole number from 2 up to its square root divides it evenly. If none do, the number is prime.
What prime really means
A prime number has a strict definition based on its divisors.
Prime numbers have exactly two positive divisors: 1 and the number itself.
Composite numbers have more than two positive divisors.
This is why 2, 3, 5, 7, and 11 are prime, while 4, 6, 8, 9, and 12 are composite.
1 is not prime. It has only one positive divisor, 1 itself. Since a prime number must have exactly two positive divisors, 1 is neither prime nor composite.
How to check if a number is prime
Step 1: Rule out numbers below 2
If a number is less than 2, it is not prime.
That means 0, 1, and negative integers are not prime numbers.
Step 2: Handle 2 separately
The number 2 is prime. It is the only even prime number.
Every other even integer is divisible by 2, so it has more than two positive divisors and cannot be prime.
Step 3: Check divisibility
For any integer greater than 2:
- If it is even, it is not prime.
- If it is odd, test whether smaller whole numbers divide it evenly.
If any test gives a remainder of 0, the number is composite.
If no possible divisor up to the required limit divides it evenly, the number is prime.
Step 4: Stop at the square root
Divisibility testing only needs to continue through the square root of the number.
You do not need to test divisors larger than that limit.
The reason is that factors occur in pairs.
If a number can be written as a × b, at least one of those two factors must be less than or equal to the square root of the number. If both factors were larger than the square root, their product would be larger than the original number.
If no divisor is found from 2 through the square root, the number is prime.
Why the square root rule works
Take 91.
Its square root is a little under 10. The relevant prime divisors to check are therefore 2, 3, 5, and 7. Since 7 divides 91 evenly, 91 is composite because 91 = 7 × 13. There is no need to continue testing larger possible divisors.
Now take 97.
Its square root is a little under 10. Testing 2, 3, 5, and 7 is enough. None divides 97 evenly, so 97 is prime.
The square-root limit reduces the number of divisibility tests while still providing a complete trial-division test for primality.
| Number | Square Root Limit | Useful Checks | Result |
|---|---|---|---|
| 29 | About 5.38 | 2, 3, 5 | Prime |
| 51 | About 7.14 | 3 divides it | Not prime |
| 97 | About 9.85 | 2, 3, 5, 7 | Prime |
Simple divisibility checks for small numbers
Several basic checks can eliminate composite numbers before longer division is needed.
- If the number is less than 2, it is not prime.
- If it is 2, it is prime.
- If it is even and greater than 2, it is not prime.
- If it ends in 5 and is greater than 5, it is not prime.
- If its digit sum is divisible by 3, the number itself is divisible by 3.
These tests do not prove that every remaining number is prime. They only eliminate numbers with easily detected divisors. Any remaining possible divisors still need to be checked through the square-root limit.
Common mistakes when checking prime numbers
Thinking 1 is prime
It is not. Prime numbers must have exactly two positive divisors. The number 1 has only one.
Thinking all odd numbers are prime
Many odd numbers are composite. For example, 9, 15, 21, and 27 are all odd, but none are prime.
Checking too many divisors
You do not need to test every smaller positive integer. Once all possible divisors through the square root have been checked, the test is complete.
Ignoring simple divisibility rules
Checks for divisibility by 2, 3, and 5 can identify many composite numbers immediately before other possible divisors are tested.
Prime numbers and composite numbers
Prime and composite numbers are distinguished by the number of positive divisors they have.
A composite number can be written as a product of smaller positive integers greater than 1. A prime number cannot. Every integer greater than 1 can be expressed as a product of prime numbers, with that prime factorization being unique apart from the order of the factors.
Prime checking therefore connects directly to factor trees, divisibility, greatest common divisors, least common multiples, and prime factorization.
Where prime checking is used
Prime numbers are used throughout elementary number theory to study divisibility, factors, multiples, and integer structure.
Primality testing is also used in computer algorithms and cryptography. For small and moderate integers, trial division through the square root provides a straightforward method. For very large numbers, computer systems can use more advanced primality-testing algorithms.
The definition remains the same regardless of the testing method: a prime number is an integer greater than 1 with exactly two positive divisors.
Checking a prime result manually
A result from the Prime Number Checker can also be checked with ordinary divisibility tests.
- Confirm that the number is an integer greater than 1.
- Check whether it is divisible by 2, 3, 5, or another possible divisor.
- Continue testing possible divisors only through the square root.
If a divisor is found, the number is composite and the divisor can be paired with the corresponding quotient. If no divisor exists through the square-root limit, the number is prime.
Prime test rule
A number is prime if it is greater than 1 and has exactly two positive divisors.
To test it by trial division, check whether any whole number from 2 up to the square root divides it evenly.
If no divisor is found in that range, the number is prime.
FAQ
Is 1 a prime number?
No. A prime number must have exactly two positive divisors. The number 1 has only one positive divisor, which is 1 itself.
Why do you only check up to the square root?
Because factors occur in pairs. If a number has a factor larger than its square root, the matching factor must be smaller than the square root. If no possible divisor is found through that limit, the number is prime.
Is every odd number prime?
No. Many odd numbers are composite, such as 9, 15, 21, and 25. Being odd only means the number is not divisible by 2.
What is the fastest way to check small numbers?
Start with divisibility checks for 2, 3, and 5. If none divides the number, continue testing possible divisors through its square root. The Prime Number Checker can perform the test automatically.
