Prime Number Checker
Verify if a number is prime, view factorizations, find adjacent primes, or list primes in a range.
367
✓ Yes, This is a Prime Number!
It is only divisible by 1 and itself.
Prime Numbers and Factorization
A prime number is a whole number greater than 1 whose only divisors are 1 and itself — 2, 3, 5, 7, 11, and so on. Every other whole number is composite and can be written as a unique product of primes (its prime factorization), for example 360 = 2³ × 3² × 5. This checker tests divisibility up to the square root of your number, which is fast and exact for values up to a trillion.
Related math tools: the GCD & LCM Calculator, the Number to Words Converter, and the Scientific Notation Converter.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Checking whether a number is prime and seeing its factors.
- Working through a number theory exercise.
- Checking a candidate number for a puzzle or a coding challenge.
- Finding the factors of a number that is not prime.
- Seeing the smallest factor, which is what a primality claim actually turns on.
Frequently Asked Questions
- How is primality tested?
- Trial division restricted to the 6k ± 1 pattern. After ruling out 2 and 3, every prime is one either side of a multiple of six, so the loop tests i and i+2 stepping by 6 and stops at √n. That is a third of the work of testing every odd number, and it is exact — no probabilistic step is involved.
- Why does it stop at a trillion?
- Because the loop runs to √n, so 10¹² costs at most a million iterations — instant. Beyond that the wait becomes noticeable and JavaScript's exact-integer range (2⁵³) starts to matter. Cryptographic sizes need Miller-Rabin; trial division here is simply faster to be certain with.
- Is 1 a prime number?
- No, by definition — a prime has exactly two distinct divisors, and 1 has one. This is not pedantry: if 1 were prime, 12 could be written as 2²×3, 1×2²×3, 1²×2²×3 and so on, and the fundamental theorem of arithmetic's UNIQUE factorisation would collapse. 0 and 1 are neither prime nor composite.
- What does the prime factorisation show?
- The unique multiset of primes whose product is your number, in exponent form — 360 = 2³ × 3² × 5. Uniqueness is the fundamental theorem of arithmetic, and it is why factorisation underpins GCD, LCM and fraction reduction. The factoriser divides out 2 first, then odd candidates only, which halves the search.
- How does it find the next prime?
- By testing each successive integer until one passes. There is no formula for 'the next prime', and gaps are irregular — 89 to 97 is a gap of 8 while 101 and 103 are twins two apart. The Prime Number Theorem says gaps near n average about ln(n), so the scan stays short even for large inputs.
Common errors and gotchas
- Treating 1 as prime, which by definition it is not.
- Assuming a number with no small factors is prime without a proper test.
- Assuming a checker's silence means prime, when a timeout and a proof look the same.
- Forgetting 2 is the only even prime, so every other even number factors.
- Using the result for cryptographic reasoning, where the numbers involved are far larger.