Home › Math › Prime Number Checker

Prime Number Checker

Check if a number is prime, and see its prime factors, divisors and the nearest primes.

You can check any whole number up to 1,000,000,000,000 (one trillion).

Result

-

Prime factorization-
Smallest factor above 1-
Number of divisors-
Divisors-
Previous prime-
Next prime-

The check tries every possible divisor up to the square root of your number, so the answer is exact, not a guess.

What is a prime number?

A prime number is a whole number greater than 1 that can be divided evenly only by 1 and itself. For example, 7 is prime because nothing except 1 and 7 divides it. A number greater than 1 that is not prime is called composite, such as 12, which divides by 2, 3, 4 and 6. The numbers 0 and 1 are neither prime nor composite.

How to use this checker

Type a whole number and the checker tells you at once whether it is prime or composite. If the number is composite, it also shows the factors that divide it, so you can see why it is not prime. Use it for homework, for puzzles or just out of curiosity.

The first 25 prime numbers

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97

There are 21 more primes between 100 and 200: 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197 and 199.

How this checker works

n is prime if no whole number from 2 up to √n divides it evenly

You only need to test divisors up to the square root of n, because any factor larger than that pairs with a smaller one. The checker skips even numbers and multiples of 3, so it is fast even for numbers close to one trillion. Because it tests every divisor, the answer is exact.

Skipping even numbers and multiples of 3 works because every prime above 3 has the form 6k − 1 or 6k + 1. That is why you only need to try divisors of that shape, which cuts the work to about a third.

Worked examples

91. Test divisors up to √91, which is about 9.5. 91 ÷ 7 = 13, so 91 = 7 × 13 and it is composite. Many people guess that 91 is prime, but it is not.

97. Nothing from 2 to 9 divides it, so 97 is prime.

221. √221 is about 14.9. Dividing by 13 gives 17, so 221 = 13 × 17 and it is composite.

1,001. It is odd and not a multiple of 3 or 5, but 1,001 = 7 × 11 × 13, so it is composite.

How many primes are there?

Primes become rarer as numbers get bigger, but they never run out. Here is how many primes there are up to different limits:

Up toNumber of primes
104
10025
1,000168
10,0001,229
100,0009,592
1,000,00078,498

Finding all primes up to a limit: the sieve

To list every prime up to a number, the ancient Sieve of Eratosthenes is a neat method. Write out all numbers from 2 to your limit, then circle 2 and cross out all its multiples. Move to the next number that is not crossed out, which is 3, circle it and cross out its multiples. Repeat, and the numbers left circled are the primes.

Prime factorization

Every whole number above 1 can be written as a product of primes in exactly one way. This is called the fundamental theorem of arithmetic. For example, 360 = 2³ × 3² × 5. The number of divisors comes from the exponents: add 1 to each and multiply, so 360 has (3+1) × (2+1) × (1+1) = 24 divisors. In the same way, 84 = 2² × 3 × 7 has 3 × 2 × 2 = 12 divisors.

Quick divisibility tests

  • 2: the last digit is even.
  • 3: the sum of the digits divides by 3.
  • 5: the last digit is 0 or 5.
  • 11: the alternating sum of the digits divides by 11.

Apart from 2 and 5, every prime ends in 1, 3, 7 or 9. But the reverse is not true: a number ending in one of those digits can still be composite, like 91 or 221.

Interesting facts

  • 2 is the only even prime number.
  • There are infinitely many primes. Euclid proved this over 2,000 years ago.
  • Twin primes are pairs that differ by 2, such as 11 and 13 or 41 and 43.
  • The largest known primes are special types called Mersenne primes, which are one less than a power of 2, such as 7 and 31. They are usually found by computers working together on a huge scale.
  • Goldbach's conjecture says every even number above 2 is the sum of two primes. It has been checked for very large numbers but has never been proved.
  • Large primes protect online banking and messaging, because multiplying two big primes is easy but splitting the product back is very hard.

Where prime numbers are used

Primes are far more than a classroom topic. Computer security uses very large primes to lock and unlock encrypted messages. Programmers use them in hash tables and random number generators to spread data evenly. Mathematicians use them to build fractions in simplest form and to find the highest common factor of two numbers. Even some insects, such as cicadas, are often said to emerge in prime-numbered year cycles.

Why is 1 not a prime number?

If 1 counted as prime, numbers would no longer have a single unique prime factorization, because you could always multiply by an extra 1. For example, 6 = 2 × 3 = 1 × 2 × 3 = 1 × 1 × 2 × 3. To keep the rule clean, mathematicians define primes as numbers greater than 1.

Related tools: LCM and HCF Calculator, Square Root Calculator and Scientific Calculator.

Prime number FAQs

Is 1 a prime number?

No. A prime number must be greater than 1 and have exactly two divisors, 1 and itself. The number 1 has only one divisor.

Is 2 a prime number?

Yes. 2 is prime, and it is the only even prime, because every other even number is divisible by 2.

How do I check if a large number is prime?

Test whether any prime up to its square root divides it. If none does, the number is prime. This calculator does that for you.

What is the difference between prime and composite numbers?

A prime has exactly two divisors, 1 and itself. A composite number has more than two divisors, so it can be split into smaller factors.

Are there infinitely many prime numbers?

Yes. Euclid proved it more than 2,000 years ago. However many primes you find, there is always a larger one.

Need another calculator?

Browse all calculators
Scroll to Top