Prime Number Checker
Check whether a number is prime and see its smallest factor.
Check whether a number is prime and see its smallest factor.
The Prime Number Checker tests whether a whole number greater than 1 has any divisors other than 1 and itself. If the number is not prime, it also shows the smallest factor found.
Prime numbers, divisible only by 1 and themselves, are the building blocks of all whole numbers through factorization, and they remain a genuinely active area of mathematical research, particularly around finding ever-larger primes and understanding their distribution.
For related tasks, try GCD Calculator, LCM Calculator or Modulo Calculator.
The calculator tests divisibility by every whole number from 2 up to the square root of the number. If none divide evenly, the number is prime.
29 is prime because no whole number between 2 and its square root divides it evenly. 30 is not prime because it is divisible by 2.
Checking 91 might seem prime at a glance since it is not obviously divisible by small numbers like 2, 3 or 5, but it actually equals 7 x 13, making it a commonly cited example of a number that looks prime but is not.
By definition, 1 is not considered a prime number even though it is only divisible by itself, and 2 is the only even prime number, since every other even number is automatically divisible by 2 in addition to 1 and itself.
A prime number has exactly two divisors, 1 and itself. To test a number you only need to try dividing by primes up to its square root, because any larger factor would pair with a smaller one. To check 97, the square root is about 9.8, so test 2, 3, 5 and 7. None divides evenly, so 97 is prime. For 91, trying 7 gives 13, so 91 equals 7 times 13 and is not prime, even though it looks like one.
Some quick rules rule numbers out. Even numbers above 2 are not prime. A number is divisible by 3 if its digits add up to a multiple of 3, so 123 is divisible by 3 because 1 plus 2 plus 3 is 6. Numbers ending in 0 or 5 are divisible by 5. For 11, subtract the sum of alternating digits and check if the result is a multiple of 11. These rules let you reject many numbers before you reach for a calculator.
Prime numbers are the building blocks of whole numbers, since every integer greater than 1 factors into primes in exactly one way. This is the basis of public-key cryptography such as RSA, where two very large primes are multiplied together, and the product is easy to compute but hard to factor. Primes are also used in hash tables and random number generation. The search for large primes continues, and the largest known primes have millions of digits.
Two is the only even prime, and 1 is not considered prime. There are infinitely many primes, a fact proved by Euclid over two thousand years ago. Pairs like 11 and 13, or 41 and 43, are called twin primes. Primes thin out as numbers get bigger, yet they never stop. The checker can handle ordinary numbers quickly, but very large values may take longer or exceed what a browser can represent exactly.
Every whole number above 1 is either prime or a product of primes in exactly one way. For example, 360 equals 2 cubed times 3 squared times 5. Prime factors let you find the GCD and LCM, simplify fractions and count divisors: add one to each exponent and multiply, which gives 4 times 3 times 2, so 360 has 24 divisors. A number that is prime has just two divisors. Factorising is easy for small numbers and very hard for very large ones, which is exactly what makes prime-based encryption secure.
To test 221, find its square root, which is about 14.9, and try the primes up to that: 2, 3, 5, 7, 11 and 13. It is odd, its digits add to 5, it does not end in 0 or 5, and 7 and 11 do not divide it. But 13 times 17 is 221, so it is not prime. To test 223, the square root is about 14.9 as well. Neither 2, 3, 5, 7, 11 nor 13 divides 223, since 223 divided by 7 is 31.86, by 11 is 20.27 and by 13 is 17.15. So 223 is prime. Numbers like 221 are tricky because they look prime until you reach the right divisor.
Primes get rarer as numbers grow, but they never stop. There are 25 primes below 100, 168 below 1,000 and 1,229 below 10,000. Roughly, the chance that a number near n is prime is about one in the natural logarithm of n, so around a million it is about one in 14. Pairs of primes that differ by two, such as 11 and 13, 17 and 19, or 41 and 43, are called twin primes, and nobody knows whether there are infinitely many. Gaps between primes can be large, and the study of how they are spread is one of the oldest fields of mathematics.
Primes are used in cryptography, where multiplying two large primes is easy but factoring the product is hard, which protects secure web connections. Hash tables often use prime sizes to spread data evenly. Random number generators and error-correcting codes rely on prime arithmetic. Some cicadas emerge in cycles of 13 or 17 years, and one idea is that prime cycles help them avoid predators with regular cycles, although the explanation is debated. Even when you never meet primes directly, many of the systems you use depend on them.
The sieve of Eratosthenes finds all primes up to a limit. Write the numbers from 2 to 50, circle 2 and cross out its multiples, then circle the next uncrossed number, 3, and cross out its multiples, and continue. You only need to continue until the circled number squared is greater than 50, which means stopping after 7. The numbers left are the primes: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43 and 47, fifteen in all. The method is over two thousand years old and is still taught because it shows how structure in numbers can be used to save work.
A prime number has exactly two positive divisors, one and itself. A composite number has more. A factor or divisor divides a number exactly, and prime factorisation writes a number as a product of primes. Coprime numbers have no common factor except one. The sieve of Eratosthenes lists primes by crossing out multiples. A Mersenne prime has the form two to a power minus one, and twin primes differ by two. The fundamental theorem of arithmetic says that every number above one has a unique prime factorisation.
To test a number you only need to check primes up to its square root. Every prime above 3 has the form 6k plus or minus 1, which is a handy filter. The number 1 is neither prime nor composite. Numbers ending in 0, 2, 4, 5, 6 or 8 are not prime, apart from 2 and 5 themselves. There are 25 primes below 100. If the digits add up to a multiple of 3, the number is divisible by 3, so it is not prime unless it is 3.
No. Prime numbers are defined as greater than 1.
No. Primality is defined for positive integers greater than 1.
Very large numbers can take longer since the check scans up to the square root, but typical everyday numbers are instant.
Prime numbers are defined as having exactly two distinct positive divisors (1 and itself); 1 has only one divisor (itself), so it fails this definition and is classified separately.
Testing divisibility only up to the square root of the number is sufficient, since if no factor exists below that point, none will exist above it either; this calculator applies that same shortcut automatically.