SpeedDrain
Published on

Prime Number Checker: Check If Any Number Is Prime Online

Authors
  • avatar
    Name
    SpeedDrain
    Twitter
Prime Number Checker: Check If Any Number Is Prime Online

Is 221 a prime number?

Give it a second. It's odd. It doesn't end in 5. The digits add up to 5, so 3 is out. Everything about it looks prime.

It isn't. 221 = 13 × 17.

That's the trap with primes. They're simple to define and surprisingly easy to misjudge by eye. Past two digits your gut stops being reliable, and that's where a prime number checker earns its place. Type a number, and you know right away whether it's prime or composite.

This guide covers both sides. You'll see how to use the free online prime number checker on Speed Drain, and you'll learn the manual methods behind it (divisibility rules, trial division, prime factorization) so you can verify answers on an exam paper or inside your own code. We'll also clear up the usual confusion around 0, 1, negative numbers and the "largest prime."

Quick Answer: How Do You Check If a Number Is Prime?

A number is prime if it is greater than 1 and divisible only by 1 and itself. To test one by hand, divide it by every prime up to its square root. If any division is exact, the number is composite. If none is, it's prime. Or skip the arithmetic and paste the number into the prime number checker.

The manual version in four steps:

  1. Confirm it's a whole number greater than 1.
  2. Estimate its square root and round down.
  3. Try dividing by each prime up to that root: 2, 3, 5, 7, 11, 13 and so on.
  4. One exact division means composite. No exact division means prime.

What Is a Prime Number?

A prime number is a natural number greater than 1 with exactly two positive divisors: 1 and itself. The first ten primes are 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29.

Take 6. It divides evenly by 1, 2, 3 and 6, so it has four divisors and isn't prime. Numbers like that are called composite.

Two small facts worth memorising. The smallest prime number is 2. And 2 is the only even prime, because every other even number is divisible by 2 and therefore has at least three divisors.

Is 1 a prime number?

No. A prime needs exactly two divisors, and 1 has only one. There's also a deeper reason. If 1 counted as prime, factorization would stop being unique: 12 could be 2 × 2 × 3, or 1 × 2 × 2 × 3, or 1 × 1 × 2 × 2 × 3, forever. Mathematicians settled the definition to keep that from happening. Some older textbooks did treat 1 as prime, which is why you'll still see the odd mention in dusty material.

Is 0 a prime number?

No. Zero isn't greater than 1, and it divides evenly into every non-zero number, so it has infinitely many divisors instead of exactly two. It isn't composite either.

Can a prime number be negative?

In school and college maths, no. Primes are natural numbers above 1. Advanced algebra has a wider idea where −3 can count as a prime element of the integers, but if homework asks "is −7 prime?", the expected answer is no. The checker only accepts positive integers for the same reason.

Prime vs Composite Numbers: What's the Difference?

A composite number has more than two positive divisors, which means it can be written as a product of smaller whole numbers.

Prime numbersComposite numbers
Positive divisorsExactly 2 (1 and itself)3 or more
Examples2, 7, 29, 974, 15, 91, 221
Smallest example24
Even examplesOnly 2Every even number above 2
Prime factorizationThe number itselfTwo or more primes multiplied

The number 1 is neither prime nor composite. And "composite" doesn't mean "big." 4 is composite, while 2,147,483,647 is prime.

How to Use the Prime Number Checker

The Prime Number Checker is a primality test and prime factor calculator in one page. Here's the flow:

  1. Open the tool.
  2. Type a positive whole number, or tap one of the presets.
  3. Read the verdict at the top: prime or composite.
  4. Scroll down for the factorization, neighbouring primes and divisors.

Here's what it returns, using 180 as the example:

  • Verdict: composite, divisible by 2.
  • Canonical prime factorization: 2² × 3² × 5.
  • Nearest primes: 179 before it, 181 after it.
  • Divisor stats: 18 divisors in total (τ) with a sum of 546 (σ).
  • Full divisor list: all 18 divisors, with a copy button.
  • Twin prime status: a flag for primes that sit two apart, like 11 and 13.

It tests integers up to 2⁵³ − 1, which is 9,007,199,254,740,991. That's a 16-digit number, plenty for homework, coding exercises and most real-world curiosity.

The presets are good teaching examples

PresetWhat it showsResult
180A composite with repeated factors2² × 3² × 5, 18 divisors
97The largest two-digit primePrime
8191A Mersenne prime (2¹³ − 1)Prime
65537A Fermat prime (2¹⁶ + 1)Prime
1000000007A large prime that programmers use as a modulusPrime
5040A highly composite number (7!)2⁴ × 3² × 5 × 7, 60 divisors

One honest note. The tool gives you the answer and the factors, not a line-by-line classroom working. If your teacher wants steps shown, the next section is your template.

Advertisement

How to Check If a Number Is Prime by Hand

Step 1: Rule out small factors with divisibility tests

These quick rules eliminate most composites before you do any real division.

DivisorRuleExample
2Last digit is 0, 2, 4, 6 or 83,486 is even, so not prime
3Digit sum is divisible by 34,521 → 4+5+2+1 = 12, so divisible by 3
5Ends in 0 or 5735 ends in 5
7Double the last digit, subtract it from the rest343 → 34 − 6 = 28, which is divisible by 7
11Alternate the signs of the digits and add2,728 → 2 − 7 + 2 − 8 = −11, so divisible by 11

Step 2: Trial division up to the square root

Why stop at the square root? If n = a × b and a is the smaller factor, then a can't be larger than √n. So if no prime up to √n divides your number, nothing bigger will either.

Example 1: is 97 prime? √97 is about 9.8, so test 2, 3, 5 and 7. It's odd, the digit sum is 16 (not a multiple of 3), it doesn't end in 5, and 7 × 14 = 98 misses by one. No divisor found, so 97 is prime.

Example 2: is 221 prime? √221 is about 14.9, so test 2, 3, 5, 7, 11 and 13. The first five fail. Then 13 × 17 = 221. Composite.

Watch out for 91. It passes the checks for 2, 3, 5 and 11, which tricks a lot of people. It's 7 × 13. Other lookalikes: 51 (3 × 17), 57 (3 × 19), 87 (3 × 29), 119 (7 × 17) and 133 (7 × 19).

Step 3: Use the 6k ± 1 shortcut

Every prime above 3 is either one less or one more than a multiple of 6: 5, 7, 11, 13, 17, 19, 23 and so on. That lets you skip about two thirds of the candidates. It narrows the list but doesn't prove anything on its own, since 25 fits the pattern and is composite.

What's the Fastest Way to Check Prime Numbers?

It depends on the size of the number and what you need back.

MethodBest forSpeedLimitation
Divisibility rulesMental checks on small numbersInstantOnly rules out small factors
Trial divisionNumbers up to a few thousand by handSlows as √n growsImpractical for 15+ digits
Sieve of EratosthenesListing every prime in a rangeFast for rangesMemory-hungry for huge ranges
Miller-Rabin testVery large integersVery fastNeeds correct bases to be exact
Online prime checkerAny number up to its cap, with factorsInstantCapped (2⁵³ − 1 on this tool)

Why trial division breaks down on big numbers

For a number near 9 × 10¹⁵, the square root is roughly 95 million. Even skipping evens, that's tens of millions of divisions for a single answer. Fine for a computer once, painful in a loop, hopeless by hand.

How the Miller-Rabin test checks large numbers

Miller-Rabin builds on Fermat's little theorem: if p is prime, then a raised to the power p − 1 leaves remainder 1 when divided by p, for any a that isn't a multiple of p. The test sharpens this by also checking square roots of 1, because modulo a prime the only square roots of 1 are 1 and −1. A composite number usually trips over this for at least one base a.

Run enough bases and a composite has nowhere to hide. For every number below 2⁶⁴, a fixed set of bases (the first twelve primes, 2 through 37) is proven sufficient, so the answer is exact rather than "probably prime." The Speed Drain checker uses this deterministic version.

What if the number is even bigger?

Past 2⁵³ − 1, standard browser number types can't store every integer exactly, so capping the input is safer than returning a rounded, unreliable answer. For larger numbers, use mathematical software such as PARI/GP or Python's sympy library. For record-sized numbers, specialised tests are used, such as the Lucas-Lehmer test for Mersenne primes.

Prime Factorization: Breaking a Number Into Primes

Prime factorization means writing a number as a product of primes. The Fundamental Theorem of Arithmetic says every whole number above 1 has exactly one such representation, ignoring the order of the factors.

A factor tree for 180:

  • 180 = 2 × 90
  • 90 = 2 × 45
  • 45 = 3 × 15
  • 15 = 3 × 5

So 180 = 2² × 3² × 5.

Once you have the factorization, other things get easy.

Counting divisors. If n = p^a × q^b × r^c, the number of divisors is (a + 1)(b + 1)(c + 1). For 180 that's 3 × 3 × 2 = 18, matching the tool's output. For 5040 (2⁴ × 3² × 5 × 7) it's 5 × 3 × 2 × 2 = 60.

GCD and LCM. Take 180 = 2² × 3² × 5 and 84 = 2² × 3 × 7. The GCD uses the lowest power of each shared prime: 2² × 3 = 12. The LCM uses the highest power of every prime: 2² × 3² × 5 × 7 = 1,260.

Prime Numbers From 1 to 100

There are exactly 25 primes between 1 and 100:

RangePrimesCount
1–102, 3, 5, 74
11–2011, 13, 17, 194
21–3023, 292
31–4031, 372
41–5041, 43, 473
51–6053, 592
61–7061, 672
71–8071, 73, 793
81–9083, 892
91–100971

Primes thin out as numbers grow, but slowly. There are 168 below 1,000, 1,229 below 10,000 and 78,498 below one million.

How to find prime numbers in a range

The classic method is the Sieve of Eratosthenes:

  1. Write out every number from 2 to your limit.
  2. Circle 2 and cross out all its multiples.
  3. Circle the next number left standing (3) and cross out its multiples.
  4. Keep going until you pass the square root of your limit.
  5. Every circled or uncrossed number is prime.

For 1–100 you only need to sieve with 2, 3, 5 and 7, since 11² = 121 is already over 100.

The checker works one number at a time rather than dumping a range. Its previous-prime and next-prime readout is handy for landing on the closest prime to any number you're working with.

Smallest and Largest Prime Numbers

The smallest prime is 2. There is no largest prime, but there is a largest known one: 2^136,279,841 − 1, a Mersenne prime with 41,024,320 digits, found on October 12, 2024 by the volunteer-run GIMPS project.

How can we be sure there's always a bigger one? Euclid's argument, from around 300 BC, still holds up. Suppose you had a complete list of primes. Multiply them all together and add 1. That new number leaves remainder 1 when divided by every prime on your list, so it's either prime itself or has a prime factor you missed. Either way, your list wasn't complete. There are infinitely many primes.

A number with 41 million digits is far beyond any browser tool, including ours. That's the territory of distributed computing and specialised tests.

Advertisement

Where Prime Numbers Are Actually Used

Primes aren't just classroom material.

  • Encryption. RSA multiplies two huge primes, each hundreds of digits long. Multiplying is easy; recovering the two primes from the product is the hard part, and that gap protects secure connections.
  • Programming. Hash tables often use prime sizes to spread data evenly, and competitive programmers use 1,000,000,007 as a modulus so often it has its own reputation.
  • Everyday maths. Simplifying fractions and finding common denominators both lean on prime factors.

If you write code, a trial-division function with the 6k ± 1 trick looks like this:

def is_prime(n):
    if n < 2:
        return False
    if n < 4:
        return True
    if n % 2 == 0 or n % 3 == 0:
        return False
    i = 5
    while i * i <= n:
        if n % i == 0 or n % (i + 2) == 0:
            return False
        i += 6
    return True

Then cross-check it against the checker. Good edge cases: 0, 1, 2, 4, 9, 25, 49, 91, 561 (a Carmichael number that fools simple Fermat tests) and 2,147,483,647 (prime). Developers who like keeping small utilities close will find more in our roundup of the best web tools for developers.

Online Checker vs Doing It by Hand

Online checkerBy hand
SpeedInstantSlow past 3–4 digits
AccuracyNo arithmetic slipsEasy to miss a divisor
ExtrasFactors, divisors, neighbouring primesYou build them yourself
ExamsNot allowed in mostRequired
Learning valueGood for checkingBest for understanding

Pros of the online checker: instant answers, free to use, handles 16-digit numbers, and returns factorization and divisors in one go.

Cons: it won't show handwritten working, it's capped at 9,007,199,254,740,991, it checks one number at a time, and you need a connection.

Practical Tips for Students, Teachers and Developers

  • Attempt first, check second. Do the problem by hand, then confirm with the tool. That's where the learning happens.
  • Memorise the first 25 primes. Everything under 100 becomes instant.
  • Trust the square root rule. Testing divisors past √n is wasted effort.
  • Use the presets in class. Ask students to predict whether 8191 or 65537 is prime before revealing the answer.
  • Test your own functions. Run the edge cases above through the checker before trusting your code.
  • Build a study setup that fits. If you're pairing maths with research and note-taking, our guide to the best AI browsers for students and researchers is a useful companion.

Frequently Asked Questions

What is a prime number?

A natural number greater than 1 with exactly two positive divisors: 1 and itself. Examples are 2, 3, 5, 7 and 11.

How do I check if a number is prime?

Divide it by every prime up to its square root. If none divides evenly, it's prime. Or enter it into the prime number checker for an instant answer.

Is 1 a prime number?

No. It has only one divisor, and counting it as prime would break the uniqueness of prime factorization.

Is 2 the only even prime number?

Yes. Every other even number is divisible by 2, so it has at least three divisors.

What is the difference between prime and composite numbers?

Prime numbers have exactly two divisors. Composite numbers have three or more. The number 1 is neither.

How do you find prime numbers quickly?

For one number, use divisibility rules, then trial division up to the square root. For a list, use the Sieve of Eratosthenes.

What are the first 10 prime numbers?

2, 3, 5, 7, 11, 13, 17, 19, 23 and 29.

How do you check large numbers for primality?

Trial division gets too slow, so computers use the Miller-Rabin test. Our checker handles integers up to 9,007,199,254,740,991. Beyond that, use software like PARI/GP or sympy.

What is prime factorization?

Writing a number as a product of primes. For example, 180 = 2² × 3² × 5. Every whole number above 1 has exactly one such form.

Can a prime number be negative?

Not in standard school maths. Primes are natural numbers greater than 1.

What is the easiest way to identify a prime number?

Check for divisibility by 2, 3, 5, 7 and 11 first. If the number survives those, keep testing primes up to its square root.

How does an online prime number checker work?

It runs a primality test, typically trial division for small inputs and Miller-Rabin for large ones. Ours uses a deterministic Miller-Rabin test, so results are exact within its supported range.

Why is 0 not a prime number?

It isn't greater than 1, and it has infinitely many divisors instead of exactly two.

What are the divisibility rules for prime numbers?

Common ones: even last digit for 2, digit sum divisible by 3, ending in 0 or 5 for 5, and the double-and-subtract trick for 7. The full table is in the manual-method section above.

Are there infinitely many prime numbers?

Yes. Euclid proved it over 2,000 years ago, and the argument still stands.

Try It on Your Own Numbers

The next time a number makes you wonder, test it. Open the free prime number checker, try your birth year or your phone number's last four digits, and look at the factors that come back. It's a surprisingly fun way to build a feel for how numbers behave.

If quick calculators are your thing, the tools page also has a percentage calculator and a loan EMI calculator. And for more lightweight utilities worth bookmarking, have a look at our list of underrated web tools.