ToolNimba Browse

🔢 Prime Number Checker

By ToolNimba Editorial Team · Updated 2026-06-19

Result
-
All divisors (factors)
-
Prime factorization
-

Enter a whole number to check whether it is prime.


Primes
-

This prime number checker tells you instantly whether a number is prime. Type any whole number and it tests primality by trial division. If the number is prime, you see why; if it is not, you get its full list of divisors and its prime factorization. There is also a second mode that lists every prime up to a limit you choose. Everything runs in your browser, so nothing you type is ever sent anywhere.

What is the Prime Number Checker?

A prime number is a whole number greater than 1 whose only divisors are 1 and itself. The first few primes are 2, 3, 5, 7, 11 and 13. Any whole number greater than 1 that is not prime is called composite, meaning it can be written as a product of smaller whole numbers. Two numbers sit outside this split on purpose: 0 and 1 are neither prime nor composite, and 1 is excluded because a prime is defined to have exactly two distinct divisors, while 1 has only one.

The checker uses trial division. To test a number n, it tries to divide n by 2 and then by the odd numbers 3, 5, 7 and so on. The key shortcut is that you only need to test divisors up to the square root of n. If n had a factor larger than its square root, the matching co-factor would have to be smaller than the square root, and that smaller factor would already have been found. So once you reach √n with no divisor found, n must be prime. This is why testing 97 only needs divisors up to 9 (since 10² = 100 is past 97), not all the way up to 96.

When a number is composite, knowing its prime factorization is often more useful than just the yes-or-no answer. Every whole number greater than 1 has exactly one prime factorization (ignoring the order of factors), a result called the fundamental theorem of arithmetic. For example 60 = 2² × 3 × 5, and there is no other way to break 60 into primes. Watch out for numbers that look prime but are not: 561 = 3 × 11 × 17 is a famous example (a Carmichael number) that passes some naive tests yet is clearly composite once you find its smallest factor, 3.

When to use it

  • Checking whether a specific number is prime for homework, a puzzle, or a coding problem.
  • Finding the prime factorization of a number to simplify fractions or find a common denominator.
  • Generating a list of all primes below a limit for a maths exercise or a programming test case.
  • Spotting that a large-looking number is actually composite by seeing its smallest factor.

How to use the Prime Number Checker

  1. Type the whole number you want to test into the input box.
  2. Read the verdict (Prime or Not prime) along with the explanation underneath.
  3. If the number is composite, review its full list of divisors and its prime factorization.
  4. To list primes, enter a limit in the second box and select List primes.

Formula & method

A whole number n is prime when n > 1 and no integer d with 2 ≤ d ≤ √n divides n exactly (n mod d ≠ 0 for every such d).

Worked examples

Test whether 97 is prime.

  1. 97 is greater than 1, so it could be prime.
  2. √97 ≈ 9.85, so we only test divisors from 2 up to 9.
  3. 97 is odd (not divisible by 2), not divisible by 3 (9 + 7 = 16), not by 5 (does not end in 0 or 5).
  4. Check 7: 97 ÷ 7 = 13.857…, not a whole number.
  5. No divisor from 2 to 9 works, so 97 is prime.

Result: 97 is prime

Test whether 91 is prime, and factor it if not.

  1. √91 ≈ 9.54, so we test divisors from 2 up to 9.
  2. 91 is odd, not divisible by 3 (9 + 1 = 10) or 5.
  3. Check 7: 91 ÷ 7 = 13 exactly, so 7 is a divisor.
  4. A divisor was found, so 91 is composite (not prime).
  5. 91 = 7 × 13, and both 7 and 13 are prime, so that is the prime factorization.

Result: 91 is not prime; 91 = 7 × 13

Test whether 561 is prime (a number that fools some quick tests).

  1. 561 is greater than 1 and odd.
  2. Add its digits: 5 + 6 + 1 = 12, which is divisible by 3, so 561 is divisible by 3.
  3. 561 ÷ 3 = 187, so a divisor exists and 561 is composite.
  4. Factor 187: 187 ÷ 11 = 17, and 17 is prime.
  5. So 561 = 3 × 11 × 17.

Result: 561 is not prime; 561 = 3 × 11 × 17

The first prime numbers

RangePrimesCount
1 to 102, 3, 5, 74
11 to 2011, 13, 17, 194
21 to 3023, 292
31 to 5031, 37, 41, 43, 475

Prime vs composite examples and factorizations

NumberPrime or composite?Prime factorization
1Neithernone (1 is a unit)
2Prime2
17Prime17
36Composite2² × 3²
51Composite3 × 17
100Composite2² × 5²

Common mistakes to avoid

  • Thinking 1 is prime. 1 is not prime. A prime must have exactly two distinct divisors (1 and itself), and 1 has only one divisor. 1 is also not composite, so it sits in its own category.
  • Forgetting that 2 is prime. 2 is the only even prime. Every other even number is divisible by 2 and therefore composite, but 2 itself has just the divisors 1 and 2, which makes it prime.
  • Testing divisors all the way up to the number. You only need to test divisors up to the square root of n. Any factor larger than √n pairs with a smaller factor below √n that you would already have found, so going further is wasted work.
  • Assuming an odd number ending in a digit other than 5 must be prime. Plenty of odd numbers are composite. 9 (3 × 3), 21 (3 × 7) and 91 (7 × 13) are all odd yet not prime. Ending in 1, 3, 7 or 9 does not guarantee primality.

Glossary

Prime number
A whole number greater than 1 whose only divisors are 1 and itself, such as 2, 3, 5 or 7.
Composite number
A whole number greater than 1 that has at least one divisor other than 1 and itself, so it can be factored into smaller whole numbers.
Divisor (factor)
A whole number that divides another exactly, leaving no remainder. For example 4 is a divisor of 12.
Prime factorization
A number written as a product of prime numbers, for example 60 = 2² × 3 × 5. Every whole number above 1 has exactly one.
Trial division
A method of testing primality by dividing a number by 2 and the odd numbers up to its square root.
Sieve of Eratosthenes
A classic algorithm that lists all primes up to a limit by repeatedly crossing out the multiples of each prime.

Frequently asked questions

Is 1 a prime number?

No, 1 is not a prime number. A prime is defined as having exactly two distinct divisors, 1 and itself, but 1 has only a single divisor. 1 is not composite either, so it belongs to its own category, often called a unit.

Is 2 a prime number?

Yes, 2 is prime, and it is the only even prime. Its only divisors are 1 and 2. Every larger even number is divisible by 2 as well as 1 and itself, which makes all other even numbers composite.

How does this prime number checker work?

It uses trial division. For a number n it checks divisibility by 2 and then by the odd numbers up to the square root of n. If no divisor is found, n is prime; if one is found, n is composite and the tool also shows its divisors and prime factorization.

Why only test divisors up to the square root?

Because divisors come in pairs that multiply to n. If n had a factor larger than its square root, the other factor in the pair would be smaller than the square root and would already have been found. So once you pass the square root with no divisor, n must be prime.

Are negative numbers prime?

By the standard convention, no. Prime numbers are defined as positive whole numbers greater than 1, so negative numbers, 0 and 1 are all excluded. This tool reports any number below 2 as not prime.

What is the largest number I can check here?

The checker handles numbers up to 1,000,000,000,000,000 (10^15) accurately and quickly, since trial division only runs up to the square root. The prime listing mode uses a sieve and is capped at 200,000 to keep the page responsive.