Skip to content
CalcTide logo
Education & Math

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.

Education & MathBy

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

  1. 1Enter the whole number you want to test in the input box. The default value of 17 shows how a prime result looks.
  2. 2Read the large verdict at the top, either Prime or Not prime, for an instant answer.
  3. 3Check the smallest factor line. For a composite number it names the first divisor above 1. For a prime it reads None.
  4. 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.
  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 it

Trial 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?

N17
ResultPrime

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?

N2
ResultPrime

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?

N1
ResultNot 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?

N12
ResultNot prime

12 is composite. Its smallest factor is 2 and its prime factorization is 12 = 2 x 2 x 3.

Is 97 prime?

N97
ResultPrime

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.

NumberPrime?Smallest factor
1NoNone
2YesNone
3YesNone
4No2
5YesNone
6No2
7YesNone
8No2
9No3
10No2
11YesNone
12No2
13YesNone
14No2
15No3
16No2
17YesNone
18No2
19YesNone
20No2

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/.

Frequently Asked Questions

A prime number is a whole number greater than 1 whose only positive divisors are 1 and itself. The first few are 2, 3, 5, 7, 11, and 13. Any whole number above 1 that is not prime is called composite.
No. 1 is neither prime nor composite. A prime must have exactly two distinct divisors, and 1 has only one, itself, so it does not qualify. Mathematicians classify 1 as a unit.
Yes. 2 is prime, and it is the only even prime. Every other even number is divisible by 2 and therefore has a factor besides 1 and itself, which makes it composite.
Try dividing it by each whole number from 2 up to its square root. If none divides it evenly, it is prime. For 53 the square root is about 7.3, so you only test 2, 3, 5, and 7, and since none divides 53, it is prime.
Prime factorization writes a number as a product of primes, such as 12 = 2 x 2 x 3 or 100 = 2 x 2 x 5 x 5. Every whole number above 1 has exactly one prime factorization, a result called the fundamental theorem of arithmetic.
The primes from 1 to 20 are 2, 3, 5, 7, 11, 13, 17, and 19, eight primes in total. After 2, every prime in this range is odd.
Because factors come in pairs that multiply to the number. If a factor were larger than the square root, its partner would be smaller than the square root and you would have already found it. Checking past the square root just repeats work.
No. Euclid proved more than two thousand years ago that there are infinitely many primes. However large a prime you find, another one always exists beyond it, though the gaps between primes tend to widen as numbers grow.
It estimates prime number checker outputs using the visible inputs and formula assumptions on this page.

Explore More in Education & Math