Loading…

Prime Number Tester

Math Algebra • Numbers

View all topics

Check whether an integer is prime, composite, or neither. A prime number has exactly two positive divisors: \[ \begin{aligned} 1 \quad \text{and} \quad n. \end{aligned} \] Trial division only needs possible divisors up to \[ \begin{aligned} \left\lfloor\sqrt n\right\rfloor. \end{aligned} \]

Number input

Use an integer with \(|n|\le 10^{12}\) for full factorization and clear divisor steps. Negative numbers, \(0\), and \(1\) are neither prime nor composite.

Quick examples

Ready
Enter an integer, then click “Calculate”.

Rate this calculator

0.0 /5 (0 ratings)
Be the first to rate.
Your rating
You can update your rating any time.

Frequently Asked Questions

What does a prime number tester do?

A prime number tester checks whether an integer has exactly two positive divisors. If it has only 1 and itself as divisors, it is prime. If it has another proper divisor, it is composite.

Is 1 prime?

No. The number 1 has only one positive divisor, so it is neither prime nor composite.

Is 2 prime?

Yes. The number 2 has exactly two positive divisors, 1 and 2. It is also the only even prime.

Why is it enough to test divisors up to sqrt(n)?

If n is composite, it can be written as n = a × b. At least one of those factors must be less than or equal to sqrt(n), so a divisor above sqrt(n) would have a matching divisor below sqrt(n).

How do you prove a number is composite?

Finding one proper divisor is enough. For example, 91 is composite because 91 = 7 × 13.

How do you prove a number is prime?

For trial division, test all possible divisors from 2 through floor(sqrt(n)). If none divide n exactly, then n is prime.

What is the smallest divisor?

The smallest divisor is the first integer greater than 1 that divides n exactly. If such a divisor is found, n is composite.

Does the calculator show factorization?

Yes. If the number is composite, the calculator shows the full prime factorization.

What is the Miller-Rabin test?

Miller-Rabin is a fast primality test based on modular arithmetic. It is often probabilistic with random bases, but it can be deterministic over certain ranges with known bases.

Why might the calculator limit very large inputs?

Full factorization and step-by-step divisor display become slow and hard to read for extremely large numbers, so the calculator limits input size for a clear browser-based educational result.