webby.tools

Prime Number Checker

Type in any whole number and instantly find out whether it's prime, composite, or the special case of neither. Switch tabs to generate a full list of every prime number up to a limit using the Sieve of Eratosthenes. Everything runs right in your browser — nothing is uploaded anywhere.

What Is a Prime Number?

A prime number is a whole number greater than 1 that has exactly two positive divisors: 1 and itself. If a number greater than 1 can be divided evenly by anything else, it's called composite instead. The first 20 primes are:

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71

Notice that 2 is in that list — it's the only even prime number, since every other even number is automatically divisible by 2 in addition to 1 and itself, which disqualifies it. Every prime after 2 is odd, but being odd is not enough on its own to make a number prime (9, 15, and 21 are all odd and all composite).

The number 1 is deliberately left off that list. By definition, a prime needs exactly two distinct positive divisors, but 1 only has one divisor — itself. That means 1 fails the definition of prime, and since it also can't be built by multiplying smaller primes together, it fails the definition of composite too. Mathematicians simply call 1 a special case: neither prime nor composite.

How to Check if a Number Is Prime by Hand

The standard manual method is called trial division, and the idea is simple: try dividing the number by every prime smaller than it, and if nothing divides evenly, it's prime. The one shortcut that makes this practical is that you never need to test past the square root of the number.

Here's why that shortcut works: divisors of a number always come in pairs that multiply back to it. If a number n has a factor larger than √n, its matching partner in that pair must be smaller than √n. So if you've already tested every candidate up to √n and found nothing, there's no way a larger factor could exist without a smaller partner you'd have already caught. For example, to check whether 97 is prime, you only need to test 2, 3, 5, and 7, since 9 × 9 = 81 and 10 × 10 = 100 — the square root of 97 sits between them. None of 2, 3, 5, or 7 divide 97 evenly, so 97 is prime.

This calculator runs the exact same process, just automated and using JavaScript's BigInt type so it stays accurate all the way up to a trillion (1012) without any floating-point rounding errors. If you'd rather see a composite number's full breakdown — every prime factor, an exponent form, and a visual factor tree — the Prime Factorization Calculator is built for exactly that.

How to Use This Tool

  1. Check a Number tab: Type a whole number (up to 1,000,000,000,000) into the box and click "Check." You'll get a PRIME, COMPOSITE, or NEITHER result, plus the nearest primes below and above your number (for numbers up to 100,000) and, for composite numbers, the smallest prime factor as a bonus fact.
  2. List Primes Up To N tab: Switch tabs, type in an upper limit (up to 1,000,000), and click "Generate List" to see the total count of primes and the primes themselves displayed as chips.
  3. Use the "Clear" button on either tab to reset the inputs and start over.

Working with permutations or combinations instead? The Factorial Calculator handles n! for those formulas. And if you're comparing two or more numbers rather than checking just one, the LCM/GCF Calculator builds directly on the same prime concepts used here.

Frequently Asked Questions

Are all prime numbers odd?

No. The number 2 is prime and even — it's actually the only even prime number that exists. Every other even number greater than 2 is divisible by 2 in addition to 1 and itself, which by definition makes it composite, not prime.

Is there a largest prime number?

No — there are infinitely many primes. This was proven over 2,000 years ago by Euclid using a short, elegant argument: assume there's a largest prime, multiply every known prime together and add 1, and that new number must either be prime itself or have a prime factor not in your original list — either way, you've found a prime bigger than the one you assumed was the largest. That contradiction means no largest prime can exist.

How are huge primes (like the ones used in cryptography) found in real life?

This calculator uses simple trial division, which is perfectly fine for everyday-sized numbers but becomes far too slow for numbers hundreds of digits long. Real-world systems that need enormous primes — like RSA encryption — instead use fast probabilistic primality tests, most commonly the Miller–Rabin test. These tests don't try every possible divisor; they run a series of mathematical checks that make it astronomically unlikely for a composite number to slip through, while running in a tiny fraction of the time trial division would take.

What are twin primes?

Twin primes are pairs of prime numbers that differ by exactly 2, like (11, 13), (17, 19), or (29, 31). Mathematicians have found enormous twin prime pairs and strongly suspect there are infinitely many of them (the "Twin Prime Conjecture"), but unlike the infinitude of primes overall, this has never actually been proven.

Why does the nearest-prime lookup stop at 100,000?

Finding the previous and next prime means trial-checking every neighboring number one at a time, which is fast for small numbers but adds up quickly as numbers get larger. Capping it at 100,000 keeps the lookup instant without risking a sluggish or frozen page for very large inputs.

Is my number uploaded anywhere when I use this tool?

No. Every calculation — trial division, the sieve, the nearest-prime search — runs locally in your own browser using JavaScript. Nothing you type is ever sent to a server, logged, or stored.

This website may contain affiliate links. If you click on an affiliate link and make a purchase, we may receive a small commission at no additional cost to you.