Prime Number Checker
Check whether any number is prime and find its smallest factor.
Enter any whole number to find out instantly whether it's prime, and if not, see its smallest factor and factorization. Great for homework, cryptography curiosity, and settling debates about numbers like 91 (it's 7 × 13).
How it's calculated
The checker tests divisibility by every integer up to the square root of the number (trial division). If none divide it evenly, the number is prime; otherwise the first divisor found is its smallest factor.
A prime number is a whole number greater than 1 whose only divisors are 1 and itself. Any larger whole number that is not prime is composite, meaning it can be written as a product of smaller whole numbers. In the checker's test, n is the number you enter, and trial division simply asks, for each candidate divisor in turn, whether n divided by that candidate leaves a remainder of zero.
Stopping at √n, the square root of n, is not a shortcut that risks missing a factor — it is exact. Factors come in pairs that multiply to n, and in every pair one member is at or below √n while the other is at or above it. So if no divisor turns up by the time the search passes √n, no divisor exists anywhere, and n must be prime. Numbers below 2 are not prime at all: 1 has only one divisor, and 0 and the negative numbers fall outside the definition entirely. When the number is composite, the checker reports the first divisor it finds, which is automatically the smallest factor; when the number is prime, that output simply shows the number itself.
Worked example
Enter 91. It looks like a plausible prime — it is odd, does not end in 5, and its digits sum to 10, so it escapes the quick tests for 2, 3 and 5. But √91 is about 9.5, so the checker only needs to test the divisors from 2 up to 9. Working through them, 7 divides 91 exactly: 91 = 7 × 13. The verdict is composite, and the smallest factor reported is 7. Contrast that with 97: it survives every test from 2 to 9, because √97 is about 9.8 and no divisor appears, so 97 is confirmed prime.
When to use it
Students use a prime checker while factorising numbers for fraction and GCF work, where knowing whether a numerator or denominator is prime tells you immediately whether any further cancelling is possible. Teachers of computing and cryptography use small primes to demonstrate why multiplying two large primes is easy but reversing the process is hard — the asymmetry that modern encryption relies on — and checking candidate numbers is the first hands-on step. It is also the quick way to settle puzzle and quiz questions, where numbers like 91 and 87 are deliberately chosen because they look prime but are not.
Common mistakes
- Calling 1 a prime number. A prime must have exactly two divisors, and 1 has only one, so it is neither prime nor composite.
- Assuming every odd number is prime. Odd composites are common — 9, 15, 21, 27, 33 and 91 all fail the test despite being odd.
- Stopping the hand test too early. Checking only divisibility by 2, 3 and 5 misses factors like 7 and 11; you must continue up to the square root of the number before declaring it prime.
- Reading the smallest factor of a prime as a real factor pair. For a prime result the checker shows the number itself in that field, because the number has no smaller factor to report.
Frequently asked questions
Is 1 a prime number?
No. A prime number must have exactly two divisors (1 and itself), and 1 has only one divisor, so it is neither prime nor composite.
Why does it only check divisors up to the square root?
If a number has a factor larger than its square root, it must also have a matching factor smaller than the square root — so checking up to √n catches every factor pair.
Is 91 prime?
No — 91 = 7 × 13. It's a classic trick question because 91 looks prime at first glance.
Are numbers below 2 ever prime?
No. Primes are defined for whole numbers greater than 1, so 1, 0 and all negative numbers are not prime. The smallest prime is 2.
What does the smallest factor mean when the number is prime?
A prime has no divisor between 2 and its square root, so there is no smaller factor to report. In that case the checker simply shows the number itself in the smallest factor field, alongside the prime verdict.
Is 2 a prime number, even though it is even?
Yes. The divisors of 2 are exactly 1 and 2, so it fits the definition perfectly. It is the only even prime — every other even number is divisible by 2 and therefore composite.
Prime checking in more depth
A second worked example: 221 and 223
Enter 221. The square root of 221 is about 14.9, so the checker only has to test the candidate divisors from 2 up to 14. The small ones fail quickly: 221 is odd, its digits sum to 5 so it is not divisible by 3, and it does not end in 0 or 5. Continuing upward, 7 leaves a remainder of 4, 11 leaves a remainder of 1, and then 13 divides it exactly: 221 = 13 × 17. The verdict is not prime, and the smallest factor reported is 13. Now change the input by just two and enter 223. Its square root is also about 14.9, so the same candidates from 2 to 14 are tested — and every one leaves a remainder, including 13, which leaves 2. With no divisor found at or below the square root, 223 is confirmed prime and the smallest factor field simply shows 223 itself. The pair shows why eyeballing is unreliable: two neighbouring odd numbers, one composite and one prime, separated only by the full test.
What the number you enter usually represents
The single number field is most often filled with a value that came from somewhere else in a problem. A student factorising 221 for a lowest-terms question learns from the smallest factor, 13, exactly where to start splitting it: 221 = 13 × 17, and since both 13 and 17 are themselves prime, the factorisation is finished in one step. A programmer choosing a table size or a step size for a hash function may test a candidate like 223, because prime sizes spread keys more evenly, and the checker gives a yes-or-no answer without a hand search. Puzzle setters rely on the same gap between appearance and fact: 221 looks unremarkable, yet it is the product of two mid-sized primes, which is precisely why it survives casual divisibility checks for 2, 3 and 5. In each case the useful output is not just the verdict but the smallest factor, because that number is the first move in whatever factorisation comes next.
Limits and edge cases of trial division
This checker uses trial division, so its effort grows with the square root of the number you enter. Testing 223 needs candidates up to about 15, testing a number near 10,000 needs candidates up to 100, and testing a number near 1,000,000 needs candidates up to 1,000 — still quick, but a number with hundreds of digits would keep the method busy far beyond any practical wait, which is why professional primality testing of very large numbers uses different mathematics. Inputs are also tidied before the test: a decimal entry is rounded down to the whole number below it, so 29.9 is tested as 29. Anything below 2 — 1, 0, and every negative number — returns a not-prime verdict with the entered value shown as the factor, matching the definition that primes begin at 2. And when the verdict is prime, treat the smallest factor field as a placeholder rather than a discovery: it repeats your number because there is no smaller factor to report.