Prime Number Calculator

Check whether a number is prime by trial division, see its full divisor list, and get its prime factorization with exponents.

Prime Number Calculator — input your values

Enter a whole number. Values above 1,000,000,000 may be slow to factor.

What does this math calculator do?

The prime number calculator tests whether a whole number is prime using trial division: it checks every integer from 2 up to the square root of the number, because any composite number must have a factor in that range. The full table of checks is shown so you can follow along.

It also lists every divisor of the number and computes its prime factorization — writing the number as a product of primes with exponents, for example 360 = 2^3 × 3^2 × 5. This is the fundamental theorem of arithmetic at work: every integer greater than 1 factors uniquely into primes.

Formula and variables

n is prime if it has exactly two divisors, 1 and n · n = p₁^e₁ × p₂^e₂ × ... × pₖ^eₖ

0 and 1 are neither prime nor composite. Negative integers are analyzed using their absolute value.

SymbolMeaning
pᵢDistinct prime factors
eᵢHow many times each prime divides n
√nUpper bound for the trial division search

Worked example

Is 29 prime, and how does 60 factor?

  1. √29 ≈ 5.39, so check 2, 3, 4, and 5: none divide 29 evenly.
  2. Therefore 29 is prime — its only divisors are 1 and 29.
  3. 60 = 2 × 30 = 2 × 2 × 15 = 2 × 2 × 3 × 5 = 2^2 × 3 × 5.

Answer: 29 is prime, and 60 = 2^2 × 3 × 5.

Tips and common mistakes

Tips

  • You only need to test divisors up to the square root of a number — anything larger pairs with a smaller factor you have already tested.
  • Primes become rarer as numbers grow, but there is no largest prime: Euclid proved infinitely many exist.
  • The only even prime is 2. Every other even number has 2 as a factor and is composite.
  • Prime factorization is the key to finding gcds and lcms without the Euclidean algorithm.

Common mistakes to avoid

  • Calling 1 a prime — it has only one divisor, so it is neither prime nor composite.
  • Forgetting that a composite number may have a large prime factor, like 2 × 97 for 194.
  • Testing divisors above the square root, which wastes time and finds only mirrored pairs.

Prime Number Calculator — frequently asked questions

What is a prime number?

A positive integer greater than 1 whose only positive divisors are 1 and itself. The first primes are 2, 3, 5, 7, 11, and 13.

Is 1 a prime number?

No. 1 has only one divisor, while primes must have exactly two, so 1 is neither prime nor composite.

How does the trial division test work?

If n is composite, it has a factor at most √n. The calculator divides n by every integer from 2 to √n; if none divide evenly, n is prime.

What is prime factorization used for?

It underpins gcd and lcm computation, fraction simplification, cryptography (large primes secure modern encryption), and many number theory proofs.

Why is 2 the only even prime?

Because every other even number is divisible by 2, giving it more than two divisors — so it is composite.

How many primes are there?

Infinitely many. Euclid proved this around 300 BC: assuming finitely many primes lets you build a new number divisible by none of them, a contradiction.