Prime Number Calculator

Written by Thierno Sadou Diallo, formula verified per our methodology • Last checked on 9/9/2026

A number is prime if it is only divisible by 1 and itself. 97 is prime (no divisor between 2 and 9), while 91 = 7 × 13 is not.

Explanation

An integer greater than 1 is called prime when it has exactly two distinct positive divisors: 1 and itself. This calculator tests primality by trial division: it checks whether the number is divisible by every integer from 2 up to its square root — it's never necessary to test beyond that point, because if a number n has a divisor greater than √n, it necessarily also has a divisor less than √n (the quotient of the two). If no divisor is found in that range, the number is prime; otherwise, the smallest divisor found is also its smallest prime factor. The number 1 is a special case deliberately excluded: by mathematical convention, it's neither prime nor composite, a definition that simplifies many arithmetic theorems (notably the fundamental theorem of arithmetic, on unique prime factorization). Prime numbers play a central role in arithmetic and modern cryptography: encryption algorithms like RSA rely on the difficulty of factoring the product of two very large prime numbers, a problem for which no fast algorithm is known to date. For a related arithmetic operation involving two numbers, see our GCD and LCM calculator.

Example: 91

Inputs

Number to test: 91.

Calculation

Testing divisors from 2 to √91 (about 9.54): 91 isn't divisible by 2, 3, 4, 5, 6, but it is by 7 (91 ÷ 7 = 13). The smallest prime factor is therefore 7.

Result

91 is not a prime number: it is the product of 7 × 13.

Frequently asked questions

Why is it enough to test divisors up to the number's square root?

Because if a number n has a divisor d greater than √n, then n ÷ d is necessarily a divisor less than √n (the product of the two equals n). In other words, any divisor beyond the square root necessarily has a smaller "partner" already tested — testing beyond that would be redundant.

Why is 1 not considered a prime number?

By mathematical convention established so that the fundamental theorem of arithmetic (every integer greater than 1 factors uniquely into a product of primes) holds without exception. If 1 were prime, this factorization would no longer be unique (you could always add extra factors of 1), which would needlessly complicate many results.

What are prime numbers used for in practice?

Beyond their intrinsic mathematical interest, prime numbers are at the heart of modern cryptography: algorithms like RSA, used to secure internet communications, rely on the difficulty of factoring the product of two very large prime numbers in a reasonable time, even with substantial computing power. Estimating how hard a related number is to guess or crack is also the logic behind our password entropy calculator.

Related resources

Similar calculators