Math

Prime Number Checker

Check whether any number is prime and find its smallest factor.

Enter any whole number to find out instantly whether it's prime, and if not, see its smallest factor and factorization. Great for homework, cryptography curiosity, and settling debates about numbers like 91 (it's 7 × 13).

Introduction

A prime number is a whole number greater than 1 whose only divisors are 1 and itself: 2, 3, 5, 7, 11, 13, 17, 19, and so on. Everything else greater than 1 is composite — built by multiplying primes together, like 91 = 7 x 13 or 100 = 2^2 x 5^2. Primes are the atoms of arithmetic: the Fundamental Theorem of Arithmetic says every integer factors into primes in exactly one way. They also underpin modern cryptography — the security of much of the internet rests on how hard it is to factor the product of two huge primes, a task that is easy to set up and practically impossible to reverse.

To test a number by hand, you only need to try prime divisors up to its square root. Why? Because factors come in pairs multiplying to the number, and in every pair at least one factor is at or below the square root — so if none divides it up to that point, no larger divisor can either. A few quick pre-checks speed things up: even numbers are divisible by 2, numbers ending in 0 or 5 by 5, and numbers whose digits sum to a multiple of 3 are divisible by 3 (147: 1+4+7 = 12, so 147 = 3 x 49). This calculator applies those rules plus trial division automatically, and it is honest about the edge cases: 1 is neither prime nor composite, and 2 is the only even prime.

How it's calculated

The checker tests divisibility by every integer up to the square root of the number (trial division). If none divide it evenly, the number is prime; otherwise the first divisor found is its smallest factor.

Worked examples

Is 97 prime?

The square root of 97 is about 9.85, so only primes up to 9 need testing: 2 (97 is odd — no), 3 (digits sum to 9+7 = 16, not a multiple of 3 — no), 5 (does not end in 0 or 5 — no), 7 (7 x 13 = 91, 7 x 14 = 98, so 97 is not a multiple — no). None divide 97, so 97 is prime. This is the largest prime below 100, a favorite exam question precisely because it requires the full checklist.

Is 91 prime? (The classic trap)

91 looks prime — it is odd, does not end in 5, and its digits sum to 10 (not a multiple of 3). But test 7: 91 / 7 = 13 exactly, so 91 = 7 x 13 and is composite. Since 7^2 = 49 sits below 91 while 11^2 = 121 sits above it, testing primes up to 7 was sufficient and caught it. Moral: always test 7 before declaring a two-digit number prime — 91, and its cousin 143 = 11 x 13, are the two most common traps.

Frequently asked questions

Is 1 a prime number?

No. A prime number must have exactly two divisors (1 and itself), and 1 has only one divisor, so it is neither prime nor composite.

Why does it only check divisors up to the square root?

If a number has a factor larger than its square root, it must also have a matching factor smaller than the square root — so checking up to √n catches every factor pair.

Is 91 prime?

No — 91 = 7 × 13. It's a classic trick question because 91 looks prime at first glance.

Related calculators

References