PN
Prime Number Checker
Instantly check if any whole number is prime, and see its smallest factor if it is not.
More Math Tools
How to Use Prime Number Checker
Type any whole number into the box. The calculator uses trial division up to the square root of the number to determine primality instantly, showing whether it is prime and, if not, its smallest factor.
About Prime Number Checker
A prime number is a whole number greater than 1 that has exactly two positive divisors: 1 and itself. In other words, a prime number cannot be evenly divided by any whole number except 1 and the number itself. The numbers 2, 3, 5, 7, 11, and 13 are all prime, because none of them can be broken down into a product of two smaller whole numbers. By contrast, a number like 12 is not prime (it is called composite) because it can be divided evenly by 2, 3, 4, and 6, in addition to 1 and 12.
Primes are often described as the "building blocks" of all whole numbers, because of a foundational result called the Fundamental Theorem of Arithmetic: every whole number greater than 1 is either prime itself, or can be broken down into a unique product of prime numbers (its prime factorization). This makes primes central to nearly every area of number theory, and they have very practical modern applications too — most notably in cryptography, where the difficulty of finding the prime factors of an extremely large number underpins the security of widely-used encryption methods like RSA, which protect online banking, secure messaging, and much of the internet's infrastructure.
The most straightforward way to check whether a number n is prime is called trial division: test whether n is evenly divisible by any whole number starting from 2 upward. If you find any divisor before reaching n itself, the number is composite (not prime). If you reach n having found no divisors, it is prime. The key efficiency trick — used by this calculator — is that you never need to check divisors larger than the square root of n. This is because factors always come in pairs that multiply to n: if n has a factor larger than its square root, it must also have a matching factor smaller than the square root, which would already have been found. For example, to check if 97 is prime, you only need to test divisors up to √97 ≈ 9.85, so checking 2 through 9 is sufficient — a huge shortcut compared to checking all the way up to 96.
A further shortcut: after checking 2, you can skip every other even number, since any even number greater than 2 is automatically divisible by 2 and therefore not prime. This calculator applies exactly that optimization, checking 2 first and then only odd candidates afterward, which roughly halves the work needed for large numbers.
Two edge cases deserve special mention, because they trip people up constantly. First, the number 1 is not prime, despite the common intuition that "1 only divides by 1 and itself" sounding like it should qualify. The formal definition of a prime requires exactly two distinct positive divisors, and 1 has only one divisor (itself), so it fails the definition — this is a deliberate convention, not an oversight, and it exists because allowing 1 to be prime would break the uniqueness part of the Fundamental Theorem of Arithmetic. Second, primality is a concept defined only for positive integers greater than 1; negative numbers and non-whole numbers do not have a meaningful "prime or not" classification in standard mathematics, so this calculator explicitly reports that primality does not apply rather than guessing based on absolute value.
The number 2 also deserves a special mention: it is the only even prime number, since every other even number is divisible by 2 and therefore has a third divisor besides 1 and itself. Every prime number after 2 must be odd.
Details & Tips
**Method (trial division):** To check if n is prime: if n ≤ 1, it is not prime. If n = 2, it is prime. If n is even and greater than 2, it is not prime (divisible by 2). Otherwise, test odd divisors from 3 up to √n; if any divides n evenly, n is composite; if none do, n is prime.
**Worked example 1 (prime):** Check 89. √89 ≈ 9.43, so test odd divisors 3, 5, 7, 9. 89 ÷ 3 ≈ 29.67 (not exact), 89 ÷ 5 = 17.8 (not exact), 89 ÷ 7 ≈ 12.71 (not exact), 89 ÷ 9 ≈ 9.89 (not exact). No divisor found up to √89, so 89 is prime.
**Worked example 2 (composite):** Check 91. √91 ≈ 9.54, so test odd divisors 3, 5, 7, 9. 91 ÷ 7 = 13 exactly. A divisor was found (7), so 91 is not prime — its smallest factor is 7 (91 = 7 × 13).
**How this calculator works:** It reads a single integer, applies the special-case rules for numbers ≤ 1 and the number 2 first, then skips straight to testing odd candidates from 3 upward, stopping as soon as either a factor is found or the candidate exceeds the square root of the input.
**Edge cases handled:**
- Numbers ≤ 1 (including 0, 1, and negative numbers within the "not prime" category conceptually) are reported as "not prime," with 1 and below given a clear note: "1 and numbers below it are not prime by definition."
- Negative numbers are treated distinctly from ≤ 1: since primality is only formally defined for positive integers greater than 1, negative input shows a dash (—) with an explanation, rather than silently checking the absolute value.
- Non-integer input (like 4.5) also shows a dash (—), since primality only applies to whole numbers.
- The number 2 is correctly identified as prime — the only even prime — without being caught by the "even numbers aren't prime" shortcut meant for larger evens.
- When a number is not prime and greater than 1, the calculator shows its smallest factor (other than 1), which is always itself a prime number.
**Practical tip:** For very large numbers, trial division up to the square root is still fast on modern computers because square roots grow much more slowly than the numbers themselves — checking a 10-digit number only requires testing divisors up to about 5 digits. If you want to see the complete prime breakdown of a composite number rather than just its smallest factor, use the companion Prime Factorization Calculator, which repeats this same trial-division process to peel off every prime factor in turn.
Frequently Asked Questions
What is a prime number?
A whole number greater than 1 that has exactly two divisors: 1 and itself, with no other whole number dividing it evenly.
Is 1 a prime number?
No. By definition, a prime must have exactly two distinct divisors, but 1 only has one divisor (itself), so it does not qualify.
Is 2 a prime number?
Yes, 2 is prime, and it is the only even prime number — every other even number is divisible by 2 and therefore has a third divisor.
Can negative numbers be prime?
No, primality is only defined for positive integers greater than 1 in standard mathematics, so negative numbers do not have a prime/composite classification.
How do you check if a large number is prime?
Test whether it is divisible by any whole number from 2 up to its square root; if none divide evenly, the number is prime.
Why only check divisors up to the square root?
Because factors come in pairs multiplying to the original number — if a factor larger than the square root existed, its smaller matching pair would already have been found.
What is a composite number?
Any whole number greater than 1 that is not prime — meaning it has at least one divisor besides 1 and itself.
What is the smallest factor of a composite number?
It is the smallest whole number greater than 1 that divides evenly into it, and this smallest factor is always itself a prime number.
Why are prime numbers important?
They are the fundamental building blocks of all whole numbers and underpin modern cryptography, which secures online banking and internet communication.
Are decimal numbers ever prime?
No, primality only applies to whole numbers, so this calculator shows a dash for non-integer input.
How does this checker handle very large numbers?
It tests divisors only up to the square root of the number, which keeps the check fast even for numbers with many digits.
Also Available As
prime checker, is it prime, primality test, prime number test, check if prime online, prime or composite calculator
Explore More Tools
View all toolsFound a Problem?
Let us know if something with Prime Number Checker isn't working as expected.
Something went wrong. Please try again.
Thanks — we'll take a look.