Prime Number Checker

Check if a number is prime, find prime factors, and generate a list of prime numbers up to N.

Is this number prime?

Prime Factorization

Primes up to N

About this calculator

Is this number prime? Type it in and the checker tells you at once, and a second box factorises any number into its prime factors. A third box generates all primes up to N using the Sieve of Eratosthenes.

The sieve is the classic algorithm for finding all the primes up to a limit, and it runs instantly in your browser for the sizes you are likely to use.

How to use it

  1. Type a number and press Check.
  2. To factorise, type a number and press Factorize.
  3. To list primes, enter N and press Generate.

Method

A prime is a whole number above 1 with exactly two divisors, 1 and itself. To test n, try dividing by every prime up to √n: if none divides it, n is prime. Factorising repeatedly divides by the smallest prime factor. A sieve lists all primes up to N by crossing off multiples of each prime.

Worked example

Examples

9797 is a prime number
9191 = 7 × 13
Primes up to 302, 3, 5, 7, 11, 13, 17, 19, 23, 29
842² × 3 × 7

Tips and common mistakes

  • 2 is the only even prime.
  • To test a number, you only need to check primes up to its square root.
  • 1 is not prime, and 0 is not either.
  • A quick check: if the digits add to a multiple of 3, the number is divisible by 3.
  • Large primes secure internet encryption (RSA).

Frequently asked questions

What is a prime number?

A number greater than 1 whose only divisors are 1 and itself.

Is 1 a prime number?

No.

What is the smallest prime?

2.

How many primes are below 100?

25.

What is prime factorisation?

Writing a number as a product of primes, such as 360 = 2³ × 3² × 5.

Are there infinitely many primes?

Yes, proved by Euclid over 2,000 years ago.

Related tools