Skip to content

Prime Number Checker and Generator

Check if a number is prime and generate lists of prime numbers in any range.

Prime Number Checker and Generator tool

Loading...

Example

Input: Is 97 a prime number?

Result: Is Prime: Yes (previous prime 89, next prime 101)

97 is not divisible by 2, 3, 5 or 7, the only primes up to sqrt(97) = 9.8, so it has no divisors other than 1 and itself.

How Many Primes Are There?

RangePrimesLargest primeShare of numbers
1 to 104740.00%
1 to 100259725.00%
1 to 1,00016899716.80%
1 to 10,0001,2299,97312.29%
1 to 100,0009,59299,9919.59%
1 to 1,000,00078,498999,9837.85%

Counted with a sieve. Generate mode lists up to 100,000 numbers at a time.

  1. Switch between Check mode to test if a number is prime or Generate mode to find primes in a range.
  2. In Check mode, enter any positive integer to instantly see if it is prime.
  3. View the prime factorization for composite numbers.
  4. In Generate mode, enter a start and end range to list all primes within it.
  5. Click the copy button to copy the prime check result or generated list.

What Makes a Number Prime?

A prime number is a whole number above 1 that only 1 and itself divide evenly, such as 2, 3, 5, 7 and 11. This tool checks whether a number is prime. If it is not, it lists the prime factors. It also shows the nearest prime below and above, and it can list every prime in a range.

The check uses trial division. If a number has any factor other than 1 and itself, at least one factor is no bigger than its square root. So to test 97 the tool only needs to try 2, 3, 5 and 7, since the square root of 97 is about 9.8. None of them divide 97, so it is prime. The tool also skips multiples of 2 and 3, which makes big checks faster. It works for any whole number up to 9,007,199,254,740,991, the largest whole number a browser stores exactly.

For a number that is not prime, you get its prime factors, such as 360 = 2 x 2 x 2 x 3 x 3 x 5. Every whole number above 1 has exactly one such list. That is why factors are useful for simplifying fractions and for finding common multiples with the GCD and LCM Calculator.

Switch to Generate mode to list every prime between two numbers. It covers up to 100,000 numbers per run and gives the count, the smallest and the largest. As the table shows, primes thin out as numbers grow. A quarter of the numbers up to 100 are prime, but only about 8% of those up to a million.

Formula / How It Works

A number n is prime if it has no divisors other than 1 and n. Trial division checks divisors up to sqrt(n).

Frequently Asked Questions

A prime number is a whole number greater than 1 with exactly two divisors: 1 and itself. The first few are 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29. A whole number above 1 that is not prime is called composite, because it can be built by multiplying smaller primes.
No. A prime must be greater than 1, so 1 is neither prime nor composite. This rule keeps prime factor lists unique. If 1 counted as prime, you could write 6 as 2 x 3, or 1 x 2 x 3, or 1 x 1 x 2 x 3, and so on. The tool reports 0 and 1 as not prime.
Every even number is divisible by 2. So any even number bigger than 2 has at least three divisors: 1, 2 and itself. That rules it out. The number 2 is prime because its only divisors are 1 and 2. All other primes are odd.
Divide by the smallest prime that goes in evenly, and repeat with what is left. For 60: 60 / 2 = 30, 30 / 2 = 15, 15 / 3 = 5, and 5 is prime. So 60 = 2 x 2 x 3 x 5. The checker does this for you and shows the factors in order.
Some encryption methods, such as RSA, rely on a one-way problem. Multiplying two very large primes is quick, but splitting the product back into those primes takes an impractical amount of time. The primes used there have hundreds of digits, far beyond what this tool checks.

Related Tools

GCD and LCM Calculator

Find the greatest common divisor and least common multiple of two or more numbers.

Math and Numbers

Number Base Converter

Convert numbers between binary, octal, decimal, hexadecimal, and any custom base.

Math and Numbers

Modulo Calculator

Calculate the remainder of division (modulo operation) for any two numbers.

Math and Numbers

Exponent and Power Calculator

Calculate powers, exponents, and exponential expressions with support for any base and exponent.

Math and Numbers

Combination and Permutation Calculator

Calculate nCr and nPr with step-by-step factorial breakdowns. Understand when order matters.

Statistics and Data