What Is a Prime Number?
A prime number is a whole number greater than 1 that has exactly two distinct positive divisors: 1 and itself. Examples include 2, 3, 5, 7, 11, and 13. Numbers greater than 1 that are not prime are called composite — they can be written as a product of smaller whole numbers. This calculator tells you instantly whether any number you enter is prime, and if not, it shows you the smallest factor that divides it.
How to Use the Calculator
Type any whole number (0 or larger) into the input box and submit. The result hero box shows YES if the number is prime or NO if it is composite. When the number is composite, the table reveals the smallest divisor greater than 1, which helps you start a full factorization.
The Formula Explained
To check primality efficiently, you only need to test divisors up to the square root of n. If n has a factor larger than its square root, it must also have a matching factor smaller than the square root, so checking that far is enough. Formally, \(n\) is prime when:
$$n \text{ is prime} \iff n > 1 \text{ and } n \bmod i \neq 0 \;\; \forall\, i \in [2, \sqrt{n}]$$that is, \(n > 1\) and \(n \bmod i \neq 0\) for every integer \(i\) from 2 up to \(\lfloor\sqrt{n}\rfloor\). This reduces the work dramatically compared to testing every number below n.
Worked Example
Take \(n = 97\). Its square root is about 9.85, so we test divisors 2, 3, 5, 7, and 9. None of them divide 97 evenly (97 is odd, not divisible by 3, 5, or 7), so 97 is prime. Now take \(n = 91\). Testing 2, 3, 5, then 7 — we find $$91 \div 7 = 13$$ exactly, so 91 is composite with smallest divisor 7.
FAQ
Is 1 a prime number? No. By definition a prime must be greater than 1, so 1 is neither prime nor composite.
Is 2 a prime number? Yes. 2 is the only even prime number; every other even number is divisible by 2.
Why only test up to the square root? Divisors come in pairs that multiply to n. If both were larger than \(\sqrt{n}\), their product would exceed n, which is impossible — so at least one divisor of any pair is \(\leq \sqrt{n}\).