How to use the Prime Number Checker
- Enter a whole number between −1,000,000,000,000 and 1,000,000,000,000.
- Read whether the value is prime, composite, or neither; 0, 1 and negative integers are not prime.
- For a composite number, check its smallest divisor and the square-root limit used by the test.
Trial division primality test
Where:
- = integer being tested
- = candidate divisor
Show as plain text
n is prime if n > 1 and no integer d from 2 through floor(√n) divides n.
Every composite integer has a factor no larger than its square root: if both factors were larger, their product would exceed the number. Checking divisors only up to the square root is therefore sufficient.
A prime number is a positive integer greater than 1 with exactly two positive factors, 1 and itself. The number 1, zero and negative integers are not prime; 1 and zero are also not composite.
Assumptions and limitations
- Inputs must be whole numbers within ±1,000,000,000,000. The cap keeps trial division practical, and this range is within JavaScript's safe integer limit.
- A decimal, blank value or number outside the limit is rejected rather than rounded or given a potentially incorrect classification.
Example: Check whether 97 is prime
- The square root of 97 is about 9.85, so test divisors 2, 3, 5 and 7.
- 97 is not divisible by any of them, so it has no factor other than 1 and 97.
- Therefore 97 is prime.
When to use the Prime Number Checker
- Checking a number from a math exercise without listing every possible divisor.
- Finding a small factor of a composite integer before continuing a factorization by hand.
- Exploring the prime factors used by the LCM calculator and GCF calculator.
Prime Number Checker FAQs
Why do you only test divisors up to the square root?
If n = a × b and both factors were greater than √n, their product would be greater than n. So every composite number has at least one factor at or below √n.
Is 1 a prime number?
No. A prime has exactly two positive factors, but 1 has only one: itself. By the same standard definition, 1 is neither prime nor composite.
What is the largest number this checker accepts?
The limit is 1,000,000,000,000 in either direction. Testing larger values by simple trial division could take too long, so the calculator rejects them rather than risk a slow or unsupported result.
How this calculator was built and tested is explained in our methodology. Spotted a problem? Let us know.