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
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?
| Range | Primes | Largest prime | Share of numbers |
|---|---|---|---|
| 1 to 10 | 4 | 7 | 40.00% |
| 1 to 100 | 25 | 97 | 25.00% |
| 1 to 1,000 | 168 | 997 | 16.80% |
| 1 to 10,000 | 1,229 | 9,973 | 12.29% |
| 1 to 100,000 | 9,592 | 99,991 | 9.59% |
| 1 to 1,000,000 | 78,498 | 999,983 | 7.85% |
Counted with a sieve. Generate mode lists up to 100,000 numbers at a time.
- Switch between Check mode to test if a number is prime or Generate mode to find primes in a range.
- In Check mode, enter any positive integer to instantly see if it is prime.
- View the prime factorization for composite numbers.
- In Generate mode, enter a start and end range to list all primes within it.
- 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
Frequently Asked Questions
Related Tools
GCD and LCM Calculator
Find the greatest common divisor and least common multiple of two or more numbers.
Math and NumbersNumber Base Converter
Convert numbers between binary, octal, decimal, hexadecimal, and any custom base.
Math and NumbersModulo Calculator
Calculate the remainder of division (modulo operation) for any two numbers.
Math and Numbers