Skip to main content

Prime Number Checker

Quickly check if a number is a prime number.

Prime Number Checker

Check if a number is a prime number.

What is a Prime Number?

A prime number is a whole number greater than 1 that has only two divisors: 1 and itself. In other words, it cannot be formed by multiplying two smaller whole numbers.

Examples:

  • 2, 3, 5, 7, 11, 13 are prime numbers.
  • 4 is not prime because it can be divided by 2 (4 = 2×2).
  • 6 is not prime because it can be divided by 2 and 3 (6 = 2×3).
  • The number 1 is not considered a prime number.

What Is a Prime Number?

A prime number is a bit like a fundamental element in chemistry—it can't be broken down into smaller whole number factors. More formally, a prime number is a whole number greater than 1 that has only two divisors: 1 and itself. These numbers are the foundation upon which all other numbers are built. I created this simple tool to instantly check if any given number is prime.

Examples of Prime and Non-Prime Numbers

  • 7 is prime: It can only be divided evenly by 1 and 7.
  • 9 is NOT prime: It can be divided by 3 (in addition to 1 and 9). A non-prime number like this is called a composite number.
  • 2 is prime: It's the only even prime number.
  • 1 is NOT prime: By definition, a prime number must have exactly two distinct factors. The number 1 only has one factor (itself).

How Does This Prime Number Checker Work?

To check if a number is prime, my calculator uses an efficient method called "trial division."

  • First, it handles the basic cases: any number less than or equal to 1 is not prime. 2 and 3 are prime.
  • Next, it checks if the number is divisible by 2 or 3. If it is, then it's not prime.
  • Finally, it checks for factors from 5 upwards. We only need to check up to the square root of the number, which makes the process much faster. It uses an optimization that checks numbers in a pattern of 6k ± 1 (5, 7, 11, 13, 17, 19, etc.), as all other numbers are divisible by 2 or 3.

If no factors are found, the number is declared prime.

Related Calculators

Probability Calculator

Random Number Gen

Ratio Calculator