Free Prime Number Checker
Check instantly whether any whole number from 2 upward is prime or composite, and see its full prime factorization with the smallest prime factor — all computed in your browser by trial division up to the square root.
Enter any whole number ≥ 2 to test whether it is prime and see its prime factorization.
No divisor exists between 2 and √97 ≈ 9.84886, so 97 is prime.
A number n ≥ 2 is prime when no integer from 2 to √n divides it. Every composite number factors uniquely into primes, e.g. 84 = 2² × 3 × 7.
Quick answer
A number n ≥ 2 is prime if it has no divisor other than 1 and itself, which you confirm by testing every integer d from 2 up to √n: if none divides n evenly, n is prime. For example, 97 is prime because √97 ≈ 9.85 and none of 2, 3, 5, 7 divides it. A composite number breaks into prime factors, e.g. 84 = 2² × 3 × 7, whose smallest prime factor is 2.
Formula & method
Primality test (trial division)
n is prime ⇔ no integer d with 2 ≤ d ≤ √n divides n
- n — the integer being tested (must be ≥ 2)
- d — candidate divisor checked from 2 to √n
You only need to test divisors up to √n: if n = a × b with a ≤ b, then a ≤ √n, so any composite has a factor at or below its square root.
Prime factorization
n = p₁^a₁ × p₂^a₂ × … × p_k^a_k
Every integer n ≥ 2 has a unique factorization into primes (Fundamental Theorem of Arithmetic). Repeatedly divide out the smallest prime that fits; the exponents aᵢ count how many times each prime pᵢ appears.
Examples
- Input
- n = 97
- Result
- Prime
- Why
- √97 ≈ 9.85, so test only 2, 3, 5, 7. 97 is odd (not ÷2), digit sum 16 (not ÷3), does not end in 0 or 5 (not ÷5), and 97 ÷ 7 ≈ 13.86 (not ÷7). No divisor ≤ √97 works, so 97 is prime.
- Input
- n = 84
- Result
- Composite — 84 = 2² × 3 × 7, smallest factor 2
- Why
- 84 ÷ 2 = 42, 42 ÷ 2 = 21 (two 2s), 21 ÷ 3 = 7 (one 3), and 7 is prime (one 7). Check: 2 × 2 × 3 × 7 = 4 × 21 = 84. The smallest prime factor is 2.
- Input
- n = 100
- Result
- Composite — 100 = 2² × 5², smallest factor 2
- Why
- 100 ÷ 2 = 50, 50 ÷ 2 = 25 (two 2s), 25 ÷ 5 = 5, 5 ÷ 5 = 1 (two 5s). Check: 2² × 5² = 4 × 25 = 100. Smallest prime factor is 2.
- Input
- n = 2
- Result
- Prime
- Why
- There are no integers d with 2 ≤ d ≤ √2 ≈ 1.41 to test, so the test passes by default. 2 has only the divisors 1 and 2, making it prime — and it is the only even prime, since every other even number is divisible by 2.
When to use this tool
- Quickly verifying whether a specific number is prime for homework, competitive math, or number-theory practice.
- Getting the full prime factorization to simplify fractions, compute a GCD or LCM, or reduce a radical.
- Finding the smallest prime factor of a number when screening candidates in coding or cryptography exercises.
- Teaching or learning the Fundamental Theorem of Arithmetic with concrete worked factorizations like 84 = 2² × 3 × 7.
Common mistakes
- Treating 1 as prime. By definition a prime has exactly two distinct divisors (1 and itself); 1 has only one divisor, so it is neither prime nor composite. This checker requires n ≥ 2.
- Testing divisors all the way up to n instead of stopping at √n. Any factor larger than √n is paired with one smaller than √n, so checking past the square root only wastes time and never finds a new factor.
- Calling 2 'not prime because it's even.' 2 is the unique even prime; only even numbers greater than 2 are guaranteed composite.
- Forgetting exponents in the factorization. 12 is 2² × 3, not 2 × 3 × 6 — every factor in a prime factorization must itself be prime, and repeated primes are written as powers.
Frequently asked questions
Is 1 a prime number?
No. A prime number has exactly two distinct positive divisors: 1 and itself. The number 1 has only one divisor, so it is classified as neither prime nor composite. That is why this tool requires the input to be 2 or greater.
Why is it enough to check divisors only up to the square root?
If n = a × b and both a and b were larger than √n, their product would exceed n, which is impossible. So at least one factor of any composite number must be ≤ √n. If no divisor up to √n is found, n cannot be composite and is therefore prime.
What is the difference between a prime and a composite number?
A prime number (≥ 2) has no positive divisors other than 1 and itself, such as 2, 3, 5, 7, 11. A composite number (≥ 4) has at least one extra divisor and can be written as a product of smaller primes, such as 84 = 2² × 3 × 7.
What does prime factorization mean?
Prime factorization expresses a number as a product of prime numbers, written with exponents for repeats — for example 100 = 2² × 5². By the Fundamental Theorem of Arithmetic this representation is unique (apart from ordering) for every integer ≥ 2.
Is 2 really a prime number?
Yes. 2 is divisible only by 1 and 2, so it satisfies the definition of a prime. It is special because it is the only even prime; every other even number has 2 as a divisor and is therefore composite.
What is the smallest prime factor used for?
The smallest prime factor is the first prime that divides a number. It is useful for breaking a number down step by step, for trial-division factoring algorithms, and for quickly detecting that an even number or a multiple of 3 or 5 is composite without full factorization.
Sources & references
- Wikipedia — Prime number
- Wikipedia — Fundamental theorem of arithmetic
- Wolfram MathWorld — Prime Number
External references open in a new tab. We are independent and not affiliated with these organizations.
- ✓ Free to use
- ✓ No sign-up required
- ✓ Runs entirely in your browser — nothing is uploaded.
- ✓ Formula and method shown above
Provided “as is” for general information only — results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.
Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards.
Related tools
- LCM & GCD CalculatorCalculators
- Factorial CalculatorCalculators
- Permutation and Combination CalculatorCalculators
- Percentage CalculatorCalculators
- Scientific CalculatorScience & Engineering
Embed this tool on your site
Free to embed, no sign-up. Paste this code where you want the prime number checker to appear: