ToolNimba

P Prime Number Calculator, Check Primes and List Them Fast

Shihab Mia By Shihab Mia ยท Updated 2026-07-06

This prime number calculator does two jobs. Enter a single whole number and it tells you instantly whether that number is prime or composite, and if it is composite it shows the prime factorization, the full list of divisors, and the nearest prime numbers on either side. Switch to list mode and it uses the Sieve of Eratosthenes to return every prime number in any range you choose, up to 1,000,000, along with a count. A number is prime when it is greater than 1 and has no positive divisors other than 1 and itself, and this tool checks that by trial division up to the square root of the number.

What is the Prime Number Calculator?

A prime number is a whole number greater than 1 whose only positive divisors are 1 and itself. The first few primes are 2, 3, 5, 7, 11, 13, and 17. Every other whole number above 1 is called composite because it can be built by multiplying smaller whole numbers together. The numbers 0 and 1 are special cases: they are neither prime nor composite, which is why this calculator asks you to start at 2. The number 2 is the only even prime, since every larger even number is divisible by 2 and therefore composite.

To decide whether a single number n is prime, this tool uses trial division. You only ever need to test possible divisors up to the square root of n. The reason is simple: if n can be written as a times b, then at least one of those two factors must be less than or equal to the square root of n. So if no whole number from 2 up to the square root of n divides evenly into n, there are no factors at all and n is prime. For a number like 97 the square root is a little under 10, so the tool only checks divisibility by 2, 3, 5, and 7 before concluding that 97 is prime. This is dramatically faster than testing every number below n.

When a number turns out to be composite, the calculator goes further and shows its prime factorization: the unique set of primes that multiply together to make it, written with exponents like 360 = 2 to the third times 3 squared times 5. This uniqueness is guaranteed by the Fundamental Theorem of Arithmetic, which says every whole number above 1 has exactly one prime factorization apart from the order of the factors. From that same factorization the tool also lists all divisors of the number and reports the next prime above it and the previous prime below it, so you get a full picture of where the number sits.

List mode answers a different question: which numbers in a range are prime? Testing each one separately with trial division works but is slow over a large range, so the tool switches to the Sieve of Eratosthenes. The sieve starts with all the numbers marked as potential primes, then repeatedly takes the next unmarked number, calls it prime, and crosses off all of its multiples. What survives to the end is exactly the set of primes. It is one of the oldest known algorithms, dating back over two thousand years, and it is still the fastest simple way to generate every prime up to a limit. To keep everything responsive inside your browser the upper bound is capped at 1,000,000; ask for more and the tool shows a friendly message instead of freezing.

Everything runs locally in your browser using plain JavaScript, so there is no waiting on a server and nothing you type is uploaded. You can copy the factorization, the divisor list, or the full list of primes with one click.

When to use it

  • Checking homework or exam answers when a class needs to confirm whether a specific number is prime or composite.
  • Getting the prime factorization of a number for fractions, greatest common divisor, or least common multiple work.
  • Generating a list of all primes up to a limit for a math project, worksheet, or programming exercise.
  • Finding the next prime above a value, which is useful when picking hash table sizes or modulus values in code.
  • Teaching the Sieve of Eratosthenes by showing the primes it produces for a chosen range.
  • Quickly listing the divisors of a number to test divisibility rules or simplify a ratio.

How to use the Prime Number Calculator

  1. Leave the tool in Check mode and type a whole number of 2 or more, such as 97, into the box.
  2. Read the verdict: prime, or composite with its factorization, divisors, and the surrounding primes.
  3. Switch to List primes mode using the button at the top to work with a range instead.
  4. Enter a start and an end value (up to 1,000,000) and press List primes to see every prime and the count.
  5. Use any Copy button to grab the factorization, the divisors, or the full list of primes.

Formula & method

Primality by trial division: a number n is prime if n is greater than 1 and no integer d from 2 up to the floor of sqrt(n) divides n evenly. If some d divides n, then n is composite. List mode uses the Sieve of Eratosthenes: mark every integer from 2 to N as prime, then for each prime p starting at 2, cross off p2, p2+p, p2+2p, and so on; the numbers still marked at the end are the primes.
Is 97 prime? Test divisors only up to the square root of 97 (about 9.85)2 no3 no5 no7 nostop at 9No divisor from 2 to 9 divides 97 evenly, so 97 has no factors but 1 and itself.97 is a prime numberPrevious prime: 89Next prime: 101Trial division only needs divisors up to sqrt(n), which makes the check fast.

Worked examples

Deciding whether 97 is prime in Check mode.

  1. The square root of 97 is about 9.85, so we only test divisors from 2 up to 9.
  2. 97 is odd, so it is not divisible by 2. It is not divisible by 3 (digits sum to 16). It does not end in 0 or 5, so not by 5.
  3. Testing 7 gives 97 divided by 7 as about 13.86, not a whole number.
  4. No divisor up to 9 works, so 97 has no factors other than 1 and itself.

Result: 97 is a prime number. Its previous prime is 89 and its next prime is 101.

Factoring the composite number 360 in Check mode.

  1. Divide out 2s: 360 = 2 times 180 = 2 times 2 times 90 = 2 times 2 times 2 times 45, so 2 appears three times.
  2. What remains is 45. Divide out 3s: 45 = 3 times 15 = 3 times 3 times 5, so 3 appears twice.
  3. What remains is 5, which is prime, so it appears once.
  4. Collecting the primes gives 2 to the third times 3 squared times 5.

Result: 360 = 2^3 x 3^2 x 5, and it has 24 divisors including 1, 2, 3, 4, 5, 6, 8, 9, 10 and so on up to 360.

The prime numbers from 1 to 100 (there are 25 of them)

RangePrime numbers
1 to 252, 3, 5, 7, 11, 13, 17, 19, 23
26 to 5029, 31, 37, 41, 43, 47
51 to 7553, 59, 61, 67, 71, 73
76 to 10079, 83, 89, 97

How many primes fall below common limits

Up toCount of primesLargest prime below the limit
1047
1002597
1,000168997
10,0001,2299,973
100,0009,59299,991
1,000,00078,498999,983

Common mistakes to avoid

  • Thinking 1 is prime. The number 1 is not prime. A prime must have exactly two distinct positive divisors, 1 and itself, but 1 only has a single divisor. The number 1 is not composite either; it sits in its own category, which is why primes start at 2.
  • Forgetting that 2 is prime. Because 2 is even, people sometimes assume it is composite. In fact 2 is the smallest and only even prime, since every other even number is divisible by 2 and therefore has 2 as a factor.
  • Testing divisors all the way up to n. You never need to test past the square root of n. If no divisor up to sqrt(n) works, none above it will either, because any factor larger than the square root is paired with one smaller than it. This is why the tool is fast even on large numbers.
  • Confusing divisors with prime factors. The prime factorization of 12 is 2 times 2 times 3, but the divisors of 12 are 1, 2, 3, 4, 6, and 12. Prime factors are the building blocks; divisors are every whole number that divides evenly, including 1 and the number itself.

Glossary

Prime number
A whole number greater than 1 whose only positive divisors are 1 and itself, such as 2, 3, 5, 7, and 11.
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.
Prime factorization
A number written as a product of primes, such as 12 = 2 x 2 x 3. By the Fundamental Theorem of Arithmetic this is unique except for order.
Divisor
A whole number that divides another number with no remainder. The divisors of 10 are 1, 2, 5, and 10.
Trial division
A method of testing primality by trying to divide the number by every integer from 2 up to its square root.
Sieve of Eratosthenes
An ancient algorithm that finds all primes up to a limit by repeatedly crossing off the multiples of each prime it finds.

Frequently asked questions

What is a prime number?

A prime number is a whole number greater than 1 that has exactly two positive divisors: 1 and itself. It cannot be made by multiplying two smaller whole numbers. The first primes are 2, 3, 5, 7, 11, and 13. Every whole number above 1 that is not prime is called composite.

How does this calculator check if a number is prime?

It uses trial division. It tries to divide your number by every integer from 2 up to the square root of the number. If none of them divide it evenly, the number has no factors other than 1 and itself, so it is prime. Stopping at the square root is enough because any larger factor is always paired with a smaller one.

Is 1 a prime number?

No. The number 1 is not prime because a prime needs exactly two distinct divisors and 1 only has one divisor, itself. The number 1 is also not composite. It is treated as a unit that belongs to neither group, so the smallest prime is 2.

What is the largest number I can check or list?

You can check a single number as large as your device handles comfortably. For listing primes over a range, the upper bound is capped at 1,000,000 so the Sieve of Eratosthenes stays fast in your browser. Ask for more and the tool shows a friendly message instead of slowing down.

How do I find the next prime after a number?

Enter your number in Check mode. Along with the prime or composite verdict, the tool reports the next prime above your number and the previous prime below it. For example, checking 100 shows the next prime is 101 and the previous prime is 97.

What is the difference between prime factors and divisors?

Prime factors are the primes that multiply to make a number, like 2 x 2 x 3 for 12. Divisors are all the whole numbers that divide it evenly, which for 12 are 1, 2, 3, 4, 6, and 12. This tool shows both when a number is composite.

Why is 2 the only even prime number?

Every even number is divisible by 2. For any even number larger than 2, that means it has 2 as a divisor in addition to 1 and itself, so it is composite. The number 2 itself only has 1 and 2 as divisors, which makes it prime, and it is the single even prime.

How many prime numbers are there below 100?

There are 25 prime numbers below 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, and 97. You can confirm this by switching to List mode and entering a range of 1 to 100.

Is my input sent to a server?

No. All calculations run locally in your browser using JavaScript, so the numbers you enter are never uploaded. The tool works offline once the page has loaded and keeps your input private on your own device.