Prime Number Calculator
- 97 is prime: trial division by every prime up to its square root (9.8) finds no divisor, so its only factors are 1 and 97.
- Its factorization is just itself: 97.
- The neighbouring primes are 89 below and 101 above.
- All primes above 3 sit one away from a multiple of 6 (in the 6k - 1 or 6k + 1 seats), a pattern prime-hunting algorithms use to skip a third of all candidates.
A prime number is a whole number greater than 1 whose only divisors are 1 and itself. By definition, 1 is neither prime nor composite. Our prime number calculator takes any whole number you enter and tells you definitively whether it is prime or composite. If the number is composite, the calculator provides its full prime factorization. For example, entering 84 yields 2^2 x 3 x 7, a typical factorization that reflects the fundamental theorem of arithmetic: every integer factors uniquely into primes. The calculator also handles special cases, noting that 2 is the only even prime while every other even number is composite.
The calculator uses trial division, the accepted standard for checking small numbers. It only tests candidate factors up to the square root of n, because if no divisor is found by then, n is prime. This method is practical for everyday numbers, though primes thin out as numbers grow—7,919 is the 1000th prime and 104,729 is the 10,000th, per the prime number theorem. Trial division is a small-number method; the largest known prime, a Mersenne prime found by GIMPS with over 41 million digits, requires far more advanced techniques. On this page, we show the formula, walk through step-by-step workings, provide worked examples, and cite sources so you can verify every result.
Worked examples
A two-digit prime
Primary result: Prime — 97 survives trial division up to its square root. (97)
| Prime check | Prime |
| Prime factorization | 97 |
| Next prime | 101 |
| Previous prime | 89 |
A highly composite number
Primary result: Composite — 84 splits into small factors: 2^2 x 3 x 7. (84)
| Prime check | Composite |
| Prime factorization | 2^2 x 3 x 7 |
| Smallest prime factor | 2 |
| Next prime | 89 |
| Previous prime | 83 |
The 1000th prime
Primary result: Prime — 7,919 is the 1000th prime. (7919)
| Prime check | Prime |
| Prime factorization | 7919 |
| Next prime | 7,927 |
| Previous prime | 7,907 |
What makes a number prime
A prime number is a whole number greater than 1 whose only divisors are 1 and itself. That means when you try to divide it by any other whole number, you always get a remainder. For example, 7 is prime because only 1 and 7 divide it evenly. A number like 12 is not prime because it can be divided by 2, 3, 4, and 6 in addition to 1 and 12. Numbers greater than 1 that are not prime are called composite numbers. When you use a prime number calculator, it checks each candidate against this definition to determine whether the number is prime or composite.
One common point of confusion is the number 1. By definition, 1 is neither prime nor composite. This is not an oversight but a deliberate choice that keeps the rules of arithmetic consistent. The fundamental theorem of arithmetic states that every integer factors uniquely into primes. For instance, 84 equals 2 squared times 3 times 7, and there is no other way to write 84 as a product of primes. If 1 were considered prime, that uniqueness would fail, because you could multiply by 1 as many times as you wanted and still get 84. Excluding 1 from the primes preserves this unique factorization rule.
The number 2 holds a special place as the only even prime. Every other even number is composite because it can be divided by 2. This makes 2 unique among primes, and it is also the smallest prime. When a prime number calculator tests an even number greater than 2, it can immediately classify it as composite without further checking. This shortcut is one reason why testing for primality can be done efficiently for many numbers.
To test whether a number is prime, you do not need to check every possible divisor up to that number. Trial division only needs candidate factors up to the square root of the number. If no divisor is found by then, the number is prime. This method works well for relatively small numbers, but it becomes impractical for very large ones. The largest known prime, a Mersenne prime found by the Great Internet Mersenne Prime Search, has over 41 million digits. Trial division is a small-number method and cannot handle numbers of that scale. Even so, primes thin out as numbers grow, a pattern described by the prime number theorem. The 1000th prime is 7,919, and the 10,000th prime is 104,729, showing how much sparser they become further along the number line.
How primality is tested
A prime number is a whole number greater than 1 whose only divisors are 1 and itself; 1 is neither prime nor composite by definition. The most direct way to test whether a number is prime is called trial division. The idea is simple: you try dividing the candidate by every possible factor, starting at 2 and working upward. If nothing divides it evenly, the number is prime. The challenge is that this becomes slow for large numbers, so mathematicians have found a way to cut the work dramatically.
Trial division only needs candidate factors up to the square root of n. The reasoning is that factors come in pairs: if a number n has a factor larger than its square root, it must also have a corresponding factor smaller than its square root. So if no divisor is found by the time you reach the square root, n is prime. Take 97 as an example. The square root of 97 is about 9.85, so you only need to test whole numbers up to 9. You check 2, 3, 4, 5, 6, 7, 8, and 9. None of them divide 97 evenly, which confirms that 97 is prime. Without the square-root bound, you would have to test every number up to 96 before reaching the same conclusion.
This method works well for small numbers, which is why a basic prime number calculator relies on it for everyday use. But primes thin out as numbers grow, and testing them becomes harder. The largest known prime, a Mersenne prime found by GIMPS, has over 41 million digits. That is far beyond trial division, which is a small-number method. For context, 7,919 is the 1000th prime and 104,729 is the 10,000th. Even those modest numbers require checking dozens of candidate factors one by one, and the cost only rises from there.
For huge candidates, mathematicians and computer programs turn to probabilistic tests such as the Miller-Rabin test. Rather than searching for divisors, these tests use number theory to check whether a candidate behaves the way a prime should. They can return a result almost instantly, even for numbers with thousands of digits. The trade-off is that they give a probability rather than absolute certainty, though repeating the test enough times makes the chance of error vanishingly small. In practice, this is how modern systems verify large primes when exact proof would take too long.
Prime factorization
When you enter 84 into a prime number calculator, the tool does not just confirm whether the number is prime. It breaks 84 down into its prime building blocks, a process called prime factorization. You can picture this with a simple factor tree. Start by splitting 84 into 2 and 42, since 84 is even and 2 is the only even prime. Then split 42 into 2 and 21. Finally, split 21 into 3 and 7. Now every branch ends in a prime number: 84 = 2^2 x 3 x 7. You can reach the same result with the ladder method, dividing repeatedly by the smallest prime that fits: 84 divided by 2 gives 42, divided by 2 again gives 21, divided by 3 gives 7, and 7 is prime.
This result is not just one possible answer among many. The fundamental theorem of arithmetic states that every integer greater than 1 factors uniquely into primes. No matter what method you use or what order you try, 84 will always break down to exactly 2^2 x 3 x 7. That guarantee of uniqueness is what makes prime factorization so powerful as a mathematical tool. A prime number is a whole number greater than 1 whose only divisors are 1 and itself, and 1 is neither prime nor composite by definition, so the factor tree always stops at numbers like 2, 3, and 7.
Prime factorization has direct practical uses, especially when you need to find the greatest common divisor (GCD) or the least common multiple (LCM) of two numbers. To find the GCD of 84 and another number, you compare their prime factorizations and keep only the prime factors they share, using the lower exponent for each. To find the LCM, you combine all prime factors from both numbers, using the higher exponent for each. Because the factorization is unique, the GCD and LCM you compute this way are also unique and exact.
For small numbers, a calculator typically finds these factors through trial division, testing candidate factors up to the square root of the number. If no divisor is found by that point, the number is prime. This method works well for everyday values but does not scale up. The largest known prime, a Mersenne prime found by GIMPS, has over 41 million digits, far beyond what trial division can handle. Still, for ordinary numbers like 84, prime factorization gives you a clear, reliable way to see how a number is built and to solve problems involving GCD and LCM.
How primes are distributed
Primes do not appear at regular intervals. The gap between one prime and the next can be as small as a single step — 2 is the only even prime, and 3 follows immediately after — or it can stretch across dozens, hundreds, or even thousands of consecutive composite numbers. As you move further along the number line, these prime gaps tend to grow wider, though not in any neat, predictable way. You might find two primes sitting close together, then a long stretch where every number factors into smaller pieces. A prime number calculator helps reveal this uneven pattern by listing primes in a chosen range, making the irregular spacing easy to see.
The prime number theorem describes how primes thin out as numbers grow. In plain terms, it says that larger ranges contain a smaller and smaller fraction of primes, and a typical number near n has roughly a 1 in ln(n) chance of being prime. The effect shows up clearly in two landmarks: 7,919 is the 1000th prime, while 104,729 is the 10,000th. To go from the 1000th to the 10,000th prime you travel an additional 96,810 numbers, yet you gain only 9,000 primes. The density drops steadily, yet the supply never runs out.
This gradual thinning does not mean large primes become rare in any practical sense. The fundamental theorem of arithmetic guarantees that every integer factors uniquely into primes, so primes act as the building blocks of all whole numbers. That role matters in cryptography, where security often depends on finding two very large primes and multiplying them together. Factoring the resulting product back into its original primes is hard, and that difficulty protects encrypted data. Trial division, which only needs candidate factors up to the square root of n, is a small-number method and cannot handle the scale involved.
The scale becomes vivid when you look at record-setting primes. The largest known prime, a Mersenne prime found by GIMPS, has over 41 million digits — far beyond what trial division can touch. Such numbers are discovered using specialized tests rather than ordinary division. Cryptographic systems do not need primes quite that large, but they do rely on primes hundreds or thousands of digits long, where checking every possible factor by hand or by trial division would take lifetimes. The distribution of primes, scattered yet infinite, is what makes modern encryption both possible and practical.
FAQs
What is a prime number?
A prime number is a whole number greater than 1 that is divisible only by 1 and itself. For example, 97 is prime because no other number divides it evenly. However, 91 is not prime because it equals 7 x 13. The number 1 is neither prime nor composite.
How can I tell if a number is prime?
Trial-divide the number by primes up to its square root. For 97, the square root is under 10, so you only need to test 2, 3, 5, and 7. Since none of these divide 97 evenly, 97 is confirmed to be a prime number.
Why do you only test up to the square root?
Factors always come in pairs around the square root. If a number n had a factor above sqrt(n), its partner below sqrt(n) would already have been found during earlier testing. This means there is no need to test beyond the square root, saving significant computation time.
What is the prime factorization of 84?
The prime factorization of 84 is 2^2 x 3 x 7. Every integer greater than 1 has exactly one prime factorization, meaning there is only one way to express it as a product of prime numbers. This unique result is fundamental to number theory.
What is the largest prime number?
There is no largest prime number. Euclid proved that the primes are infinite, so they continue without end. However, the largest known prime currently identified is a Mersenne prime with over 41 million digits, discovered by the GIMPS distributed computing project.
Is 1 a prime number?
No, 1 is not a prime number. By definition, a prime has exactly two divisors, but 1 has only one divisor. Calling 1 prime would also break unique factorization, since you could multiply by 1 repeatedly and get multiple factorizations for the same number.