Prime Number Checker
Check if a number is prime, find prime factors, and list primes in a range.
Check If a Number Is Prime
Prime Factors
List Primes in Range
What is a Prime Number?
A prime number is a whole number greater than one whose only positive divisors are one and itself. In other words, you cannot divide it evenly by anything else. The first primes are two, three, five, seven, eleven, and thirteen, and the list continues forever: Euclid proved more than two thousand years ago that there is no largest prime.
Numbers greater than one that are not prime are called composite, because they can be built by multiplying smaller whole numbers together. The number one is a special case: it has only a single divisor, so it is classified as neither prime nor composite. This is one of the most common sources of confusion, and this checker reports it explicitly.
This page bundles three related tools. The first checks whether a single number is prime using trial division, testing divisibility by odd numbers up to the square root of the input, and reports a divisor when the number turns out to be composite. The second performs prime factorization, breaking a composite down into its prime building blocks and grouping repeated factors into exponent form. The third lists every prime inside a range using the classic Sieve of Eratosthenes.
All three run entirely in your browser. The primality check stops at the square root of the number, which is efficient because if a number had a factor larger than its square root, it would necessarily also have a matching factor smaller than the square root. The factorization loop uses the same idea, and the sieve precomputes primes across the whole range in one pass rather than testing each candidate separately.
Key Concepts
- Prime — an integer greater than 1 with exactly two positive divisors, one and itself.
- Composite — an integer greater than 1 with more than two divisors, formed from smaller factors.
- Factor — a whole number that divides another exactly, leaving no remainder.
- Prime factorization — the unique expression of a composite number as a product of primes.
- Trial division — the primality test that checks divisors only up to the square root of the number.
- Sieve of Eratosthenes — an efficient method that marks multiples to find every prime in a range at once.
How to Use
- Check whether a number is prime — Enter a positive integer and press Check Prime to see the verdict and, when it is composite, one or more of its divisors.
- Find the prime factors — Enter a value of 2 or more and press Factorize to see the full list of prime factors together with the condensed exponent form.
- List primes in a range — Set the From and To fields and press List Primes to run the Sieve of Eratosthenes across that interval.
- Read the count and the list — The tool reports how many primes fall inside the range and prints them, capping the printed sequence at 100 values with a note about the remainder.
- Check the boundary rules — The checker rejects values below 1 for the primality test and below 2 for factorization, and it warns when the From value is greater than the To value.
Prime Count Reference
Primes become sparser as numbers grow, so the count within a range is a useful sanity check when you are testing the tool. The table below lists how many primes exist up to several round upper bounds, which you can verify by entering each bound as the To value and 1 as the From value.
| Range | Primes | Notes |
|---|---|---|
| 1 to 100 | 25 | Largest is 97 |
| 1 to 500 | 95 | Largest is 499 |
| 1 to 1000 | 168 | Largest is 997 |
| 1 to 2000 | 303 | Largest is 1999 |
| 1 to 5000 | 669 | Largest is 4999 |
| 1 to 10000 | 1229 | Largest is 9973 |
Worked Examples
- 97 — reported as prime with exactly two factors, 1 and 97, because no odd divisor up to its square root divides it.
- 1 — reported as not prime with the note that it is neither prime nor composite.
- 84 — composite; its divisors include 2, 3, 4, 6, 7, and more. Factorization gives 2 × 2 × 3 × 7, shown in exponent form as 2² × 3 × 7.
- 360 — factorization is 2 × 2 × 2 × 3 × 3 × 5, condensed to exponent form 2³ × 3² × 5.
- 2 — the smallest prime; it is the only even prime, and factorizing it reports that it is already prime.
- Range 1 to 1000 — the sieve finds 168 primes; because that exceeds 100, only the first 100 are printed and the rest are summarised as a remainder.
Tips and Common Mistakes
- One is not prime — the most frequent error is calling 1 a prime; the tool correctly classifies it as neither prime nor composite.
- Two is prime and even — do not assume all primes are odd; 2 is the sole even prime.
- Factorization needs values of 2 or more — entering 0 or 1 in the factorization box is rejected because those numbers have no prime factors.
- Keep From below To — the sieve reports an error when the start of the range is larger than the end, so set the bounds in order.
- Large ranges are capped in display only — the count is always accurate, but the printed list stops at 100 primes to keep the page readable.
- Every composite has a unique factorization — the prime factor breakdown is unique up to ordering, a property known as the fundamental theorem of arithmetic.
Common Use Cases
Prime numbers are a foundational idea in mathematics and computing, and the three tools here cover the situations where you need to test, break down, or enumerate them.
- Math homework and study — verify whether a number is prime and check a factorization step by step.
- Simplifying fractions — prime factors reveal the greatest common divisor so a fraction can be reduced to lowest terms.
- Cryptography background — prime testing and factorization underpin public-key systems, making them valuable to understand.
- Computer science practice — explore trial division and the Sieve of Eratosthenes as classic introductory algorithms.
- Puzzle and game solving — factor-based number puzzles and riddles often depend on prime structure.
- Teaching demonstrations — show how prime density thins out as the range extends by comparing prime counts.
Frequently Asked Questions
What is a prime number?
A prime number is a positive integer greater than 1 that has exactly two factors: 1 and itself. For example, 2, 3, 5, 7, 11, and 13 are prime numbers.
What is prime factorization?
Prime factorization is breaking a composite number down into the primes that multiply together to make it. For example, 84 = 2 × 2 × 3 × 7, and 360 = 2³ × 3² × 5 in exponent form.
Is 1 a prime number?
No. A prime number must have exactly two distinct positive divisors. The number 1 has only one divisor, itself, so it is neither prime nor composite.
How is primality tested?
The checker uses trial division. It first handles small cases, then tests odd divisors from 3 up to the floor of the square root of the number, returning false as soon as any divisor is found.
Is 2 a prime number?
Yes. 2 is the smallest prime and the only even prime number, because every other even number is divisible by 2.
How are primes listed in a range?
The range tool uses the Sieve of Eratosthenes, marking multiples of each prime across the interval. It reports the total count and prints the primes, capped at 100 shown values.
What is the largest prime number?
There is no largest prime number. Euclid proved over 2,000 years ago that there are infinitely many. The largest known prime has tens of millions of digits.
Does the tool work offline?
Yes. Every check, factorization, and sieve runs in your browser with JavaScript, so no number you enter is ever sent to a server.