Prime Number Checker
17 is a prime number because its only divisors are 1 and 17. This prime number checker takes any whole number and tells you at once whether it is prime, along with its smallest factor, its full prime factorization, and the closest primes just above and below it. A prime number is a whole number greater than 1 that has no positive divisors other than 1 and itself. Enter 17 and the tool confirms it is prime with no factor between 2 and 16. Enter 12 and it reports that 12 is not prime, its smallest factor is 2, and its factorization is 2 x 2 x 3. The checker uses trial division up to the square root of the number, the same method taught in school, so the reasoning behind every verdict stays easy to follow. Students verifying homework, programmers testing edge cases, and anyone curious about a lottery number or a house number can drop it in and get a clear answer plus the surrounding context.
Quick answer
A prime number is a whole number above 1 whose only divisors are 1 and itself, so 2, 3, 5, 7, and 11 are prime.
Result
Prime
Prime factorization
17 is prime
Smallest factor
None
Next prime
19
Previous prime
13
What this tells you
- •A prime number is a whole number above 1 whose only divisors are 1 and itself, so 2, 3, 5, 7, and 11 are prime.
- •The number 1 is not prime and not composite, because prime numbers are defined as having exactly two distinct divisors and 1 has only one.
- •2 is the only even prime. Every other even number is divisible by 2, which gives it a factor besides 1 and itself.
- •To test a number you only need to try divisors up to its square root, because any larger factor pairs with a smaller one already checked.
- •A composite number is any whole number above 1 that is not prime, meaning it has at least one divisor between 2 and itself minus one.
- •Every whole number above 1 has exactly one prime factorization, a fact known as the fundamental theorem of arithmetic.
How to Use
- 1Enter the whole number you want to test in the input box. The default value of 17 shows how a prime result looks.
- 2Read the large verdict at the top, either Prime or Not prime, for an instant answer.
- 3Check the smallest factor line. For a composite number it names the first divisor above 1. For a prime it reads None.
- 4Look at the prime factorization to see the number broken into its prime building blocks, such as 100 = 2 x 2 x 5 x 5.
- 5Use the next prime and previous prime values to see the closest primes on either side, which is handy for filling in a list of primes.
How It Works
Formula
n is prime if no whole number from 2 to sqrt(n) divides itTrial division checks every candidate divisor from 2 up to the square root of n. If none divides n evenly, then n is prime. The square root cutoff works because divisors come in pairs that multiply to n. If a factor larger than sqrt(n) existed, its partner would be smaller than sqrt(n) and would already have been found. For 97 the square root is about 9.85, so the checker only tests 2, 3, 5, and 7. None divides 97, so 97 is prime. For 91 the same short list reveals that 7 divides it, giving 91 = 7 x 13, so 91 is composite. The smallest factor is found first, and repeatedly dividing by the smallest remaining factor produces the complete prime factorization.
Calculation note: values are processed in the order shown above, using the current input units.
Worked Examples
Is 17 prime?
No whole number from 2 to 4 divides 17 evenly, so its only divisors are 1 and 17. The next prime is 19 and the previous prime is 13.
Is 2 prime?
2 is the smallest prime and the only even one. It has no previous prime because nothing prime sits below it. The next prime is 3.
Is 1 prime?
1 is neither prime nor composite. Primes need exactly two distinct divisors, and 1 has only itself. The next prime is 2.
Is 12 prime?
12 is composite. Its smallest factor is 2 and its prime factorization is 12 = 2 x 2 x 3.
Is 97 prime?
Testing 2, 3, 5, and 7 finds no divisor, so 97 is prime. It is one of the larger two-digit primes, sitting between 89 and 101.
Primes and Smallest Factors from 1 to 20
Whether each number from 1 to 20 is prime and its smallest divisor above 1.
| Number | Prime? | Smallest factor |
|---|---|---|
| 1 | No | None |
| 2 | Yes | None |
| 3 | Yes | None |
| 4 | No | 2 |
| 5 | Yes | None |
| 6 | No | 2 |
| 7 | Yes | None |
| 8 | No | 2 |
| 9 | No | 3 |
| 10 | No | 2 |
| 11 | Yes | None |
| 12 | No | 2 |
| 13 | Yes | None |
| 14 | No | 2 |
| 15 | No | 3 |
| 16 | No | 2 |
| 17 | Yes | None |
| 18 | No | 2 |
| 19 | Yes | None |
| 20 | No | 2 |
The eight primes from 1 to 20 are 2, 3, 5, 7, 11, 13, 17, and 19. Notice that after 2, every prime is odd, and the gaps between consecutive primes stay small at this range before slowly widening for larger numbers.
What Prime Numbers Are and How to Test Them
A prime number is a whole number greater than 1 that cannot be formed by multiplying two smaller whole numbers. Put another way, its only positive divisors are 1 and the number itself. The first several primes are 2, 3, 5, 7, 11, 13, 17, and 19. Any whole number above 1 that is not prime is called composite, meaning it can be written as a product of smaller factors. The number 4 is composite because 4 = 2 x 2, and 15 is composite because 15 = 3 x 5. Primes act as the building blocks of arithmetic, since every whole number above 1 is either prime itself or a unique product of primes.
Trial division is the most direct way to test a number by hand or by computer. To check whether n is prime, try dividing it by each whole number starting at 2. If any of them divides n with no remainder, then n has a factor besides 1 and itself, so it is composite. If you reach the square root of n without finding a divisor, then n is prime. The square root shortcut matters because factors pair up. Every factor larger than the square root of n is matched by a partner smaller than the square root, so once you have checked up to the square root you have effectively checked everything. Testing 89 only requires trying divisors up to 9, which keeps the work short even for fairly large numbers.
The number 1 is deliberately left out of the primes, and this is a definition worth understanding rather than memorizing. A prime is defined as having exactly two distinct positive divisors, 1 and itself. The number 1 has only a single divisor, itself, so it fails that test. Keeping 1 out also keeps the fundamental theorem of arithmetic clean, because it guarantees that every number has exactly one prime factorization. If 1 counted as prime, you could pad any factorization with extra factors of 1 and the uniqueness would break down. So 1 is classified as a unit, neither prime nor composite.
Common mistakes
- Counting 1 as prime. A prime needs exactly two distinct divisors, and 1 has only one, so 1 is neither prime nor composite.
- Assuming all odd numbers are prime. Many odd numbers are composite, such as 9, 15, 21, and 25, each of which has an odd factor above 1.
- Forgetting that 2 is prime. Because it is the only even prime, people sometimes skip it, but 2 has no divisor other than 1 and itself.
- Testing divisors all the way up to n. You only need to check up to the square root of n, since any larger factor pairs with a smaller one already tested.
- Confusing prime factorization with listing all factors. The factorization of 12 is 2 x 2 x 3, while its full list of divisors is 1, 2, 3, 4, 6, and 12.
- Thinking a number ending in a certain digit must be prime. A number ending in 0, 2, 4, 6, or 8 is divisible by 2, and one ending in 0 or 5 is divisible by 5.
Embed this calculator on your site
Drop this single line where you want the calculator to appear. It is responsive, mobile-friendly, resizes automatically, and is free to use with attribution.
<script src="https://calctide.com/embed.js" data-tool="prime-number-checker" async></script>Preview the embed at /embed/prime-number-checker/.