Prime number calculator
Pick a mode and enter a whole number. The calculator tells you if it is prime, breaks it into prime factors, or lists all the primes up to your limit.
Use it to test primality, find a prime factorization like 360 = 2³ × 3² × 5, or list every prime up to N.
97
Check shows a green or red badge and, when the number is composite, its smallest prime factor. Factorize shows the prime factors as chips. List shows a count and a grid of every prime up to N.
How does it work?
1. Primality by trial division up to √n. 2. Prime factorization. 3. All primes up to n via the sieve of Eratosthenes.
Prime number definitions
- n
- The whole number you enter (at least 2).
- p
- A prime: a whole number greater than 1 with no divisors other than 1 and itself.
- a_i
- How many times the prime pᵢ appears in the factorization.
7 is prime. 9 is not (smallest factor 3). 360 = 2³ × 3² × 5. Primes up to 20: 2, 3, 5, 7, 11, 13, 17, 19.
Method & sources
A prime is a whole number greater than 1 whose only divisors are 1 and itself. Primality uses trial division up to the square root of N; factorization repeats the same division. The prime list uses the sieve of Eratosthenes.
Sources
Where this method comes from — use these references to understand the formula, assumptions, and limits.
- Prime numbers — mathematical definition — On-Line Encyclopedia of Integer Sequences, verified 2026-06-10
How we calculate
- A prime is a whole number greater than 1 whose only divisors are 1 and itself.
- Primality uses trial division up to the square root of N; factorization repeats the same division.
- The prime list uses the sieve of Eratosthenes.
- To stay fast and deterministic, N is capped at 1,000,000 for checking and factorizing and at 100,000 for listing.
Rounding
All inputs and outputs are whole numbers, so no rounding is applied.
What this calculator does
A prime number is a whole number greater than 1 that can only be divided evenly by 1 and itself. This tool has three modes: check a single number for primality, break a number into its prime factors, or list every prime up to a limit.
How to use it
- Choose a mode: check, prime factorization, or list primes.
- Enter a whole number of at least 2.
- Read the badge, the factor chips, or the prime grid below.
A worked example
Checking 97 returns a green Prime badge. Factorizing 360 gives 2³ × 3² × 5. Listing primes up to 20 returns 2, 3, 5, 7, 11, 13, 17, and 19.
How it works
Primality and factorization use trial division: a number is tested for divisibility by 2, 3, and then by candidates up to its square root. Listing uses the sieve of Eratosthenes, which crosses out multiples of each prime in turn. To keep results instant, the number is capped at one million for checking and factorizing and at one hundred thousand for listing.
Common mistakes
- Treating 1 as prime. By definition, 1 is not a prime number, so the smallest input is 2.
- Assuming all odd numbers are prime. 9, 15, and 21 are odd but composite.
- Confusing factors with prime factors. The prime factorization only uses prime building blocks, with exponents for repeats.
When it's useful
Homework and number-theory practice, simplifying fractions, finding greatest common divisors, and quick checks of whether a number can be broken down further.
FAQ
- What is a prime number?
- A prime number is a whole number greater than 1 whose only divisors are 1 and itself. The first primes are 2, 3, 5, 7, 11, and 13.
- Is 1 a prime number?
- No. By definition a prime has exactly two distinct divisors, 1 and itself, and 1 has only one divisor. The smallest prime is 2.
- What is a prime factorization?
- It is the unique way of writing a number as a product of primes. For example, 360 = 2 × 2 × 2 × 3 × 3 × 5, written 2³ × 3² × 5.
- How does the calculator decide if a number is prime?
- It tests divisibility by 2, by 3, and then by candidates of the form 6k ± 1 up to the square root of the number. If none divide it evenly, the number is prime.
- Why is there a limit on the number I can enter?
- The limit keeps the calculation instant and deterministic in the browser. Checking and factorizing accept up to one million; listing accepts up to one hundred thousand.
- Can I share a calculation?
- Yes. Use Share to copy a link that reopens the calculator with the same mode and number.
Related calculators
- Statistics calculatorRun descriptive statistics over a list of numbers.
- Percentage calculatorWork out a percentage of any number.
- Fraction calculatorAdd, subtract, multiply, and divide fractions.
- Scientific calculatorUse trig, logs, and powers in a full scientific calculator.
- Basic calculatorDo quick everyday arithmetic.
Embed this calculator
Add this calculator to your own site. The snippet includes the calculator iframe and a small attribution link:
<iframe src="https://wisecalcs.com/embed/en/prime-numbers" width="100%" height="520" style="border:0" loading="lazy"></iframe>
<p>Calculator from <a href="https://wisecalcs.com/en/math/prime-numbers">WiseCalcs</a></p>