Prime Number Calculator
Check whether a number is prime, or list all prime numbers up to a given limit.
What is a prime number?
A prime number is a whole number greater than 1 that has exactly two positive factors: 1 and itself. For example, 7 is prime because its only positive factors are 1 and 7. By contrast, 12 is composite because it can also be divided evenly by 2, 3, 4 and 6.
The calculator can check one whole number or generate a list of prime numbers up to a limit. Use the first mode when you want a direct prime-or-composite answer, and the second when you want to explore a range.
How to use the Prime Number Calculator
- Choose Check if a Number is Prime or List Primes up to a Limit.
- Enter a whole number. Example placeholders are shown lightly and are not submitted as values.
- Select Calculate.
- For a prime number, the result also shows its prime position and neighboring primes.
How the prime check works
For a number n, it is enough to test possible divisors from 2 through √n. If a composite number has a factor larger than its square root, the matching factor in that pair must be smaller than the square root. Finding no divisor in that smaller range is therefore enough to establish primality.
Worked example: Is 97 prime?
√97 is approximately 9.85, so we only need to test prime divisors up to 9.85: 2, 3, 5 and 7.
- 97 is not even, so it is not divisible by 2.
- 9 + 7 = 16, so it is not divisible by 3.
- It does not end in 0 or 5, so it is not divisible by 5.
- 97 ÷ 7 is not a whole number.
None of the required divisors divide 97 evenly, so 97 is prime. It is the 25th prime number; the previous prime is 89 and the next is 101.
Prime numbers from 1 to 100
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
There are 25 prime numbers between 1 and 100. Notice that 1 is not included, and 2 is the only even prime.
Prime numbers vs. composite numbers
A whole number greater than 1 is either prime or composite. Prime numbers have exactly two positive factors. Composite numbers have more than two. The number 1 is a special case: it is neither prime nor composite.
Assumptions and limits
- The checker accepts whole numbers 2 or greater. Decimals, negative values, 0 and 1 are not prime inputs.
- The list mode is capped at 10,000 and displays at most 200 primes to keep the browser result readable.
- This tool is intended for everyday and educational prime-number checks, not specialized large-integer cryptographic primality testing.
Tips and common mistakes
- You only need to test divisors up to the square root: for 97, checking 2, 3, 5 and 7 is enough because √97 ≈ 9.8.
- Every prime above 3 is one more or one less than a multiple of 6 (like 97 = 96 + 1), but not every such number is prime (25 = 24 + 1).
- List mode shows up to 200 primes; for larger limits, narrow the range.
- 1 is not prime, and 2 is the only even prime.