Prime Factorization

Prime Number Calculator

Check if a number is prime, find prime numbers in a range, get prime factorization, and find the next or previous prime. All calculations are shown with step-by-step explanation.

Is It a Prime Number?

Enter any whole number to check whether it is prime or composite, with a full step-by-step explanation.

Result
Number to Check
Enter a whole number (up to 9,999,999)

Prime Factorization

Break any number down into its prime factors, shown step by step.

Result
Number to Factorize
Enter a whole number greater than 1 (up to 9,999,999)

Find Primes in a Range

List all prime numbers between two values. Range limited to 10,000 numbers for performance.

Result
From
To
Maximum range: 10,000 numbers

Next and Previous Prime

Find the nearest prime number above or below any given number.

Result
Number
Enter a whole number (up to 9,999,999)

About Prime Numbers

What is a Prime Number?

A prime number is a whole number greater than 1 that has exactly two divisors: 1 and itself. For example, 7 is prime because no whole number other than 1 and 7 divides into it evenly. The number 1 is not considered prime by definition.

What is a Composite Number?

A composite number is a whole number greater than 1 that has more than two divisors. For example, 12 is composite because it is divisible by 1, 2, 3, 4, 6, and 12.

How to Check if a Number is Prime

The most efficient basic method is trial division up to the square root of the number. If no integer from 2 up to the square root divides the number evenly, then the number is prime.

To check if n is prime:
1. If n is less than 2, it is not prime.
2. If n equals 2, it is prime.
3. If n is even (divisible by 2), it is not prime.
4. Check all odd numbers from 3 up to sqrt(n).
5. If none divide n evenly, then n is prime.

What is Prime Factorization?

Prime factorization is expressing a number as a product of prime numbers. For example: 360 = 2 x 2 x 2 x 3 x 3 x 5 = 2^3 x 3^2 x 5. Every integer greater than 1 has a unique prime factorization, which is known as the Fundamental Theorem of Arithmetic.

Special Cases

0 and 1 are neither prime nor composite. 2 is the only even prime number. All other even numbers are composite because they are divisible by 2. The number 2 is also the smallest prime number.

How Many Prime Numbers Are There?

There are infinitely many prime numbers. This was proved by the ancient Greek mathematician Euclid around 300 BC. As numbers get larger, primes become less frequent, but they never stop completely.