Prime Number Checker

Check if a number is prime.

Output appears here.

Prime numbers — divisible only by 1 and themselves — seem like a simple schoolyard concept, yet they underpin the encryption protecting essentially every secure connection on the internet. This tool instantly checks whether a number is prime.

A 2,300-year-old proof that primes never run out

Euclid, in his foundational work "Elements" written around 300 BC, proved that there are infinitely many prime numbers — a genuinely elegant argument (assume a largest prime exists, then construct a new number that must either be prime itself or have a prime factor not on your original list, contradicting the assumption) that remains one of the most celebrated proofs in all of mathematics, still taught essentially unchanged over two millennia later. Since Euclid's time, primes have gone from a subject of pure mathematical curiosity to a matter of direct practical importance, since modern public-key cryptography (including the RSA algorithm, published in 1977) relies specifically on the practical difficulty of factoring the product of two very large prime numbers.

How this tool checks primality

For smaller numbers, the tool checks divisibility by testing whether any integer from 2 up to the square root of your number divides it evenly — a well-established optimization, since if a number has a factor larger than its square root, it must also have a corresponding factor smaller than the square root, meaning you never need to check beyond that point to be certain.

Where checking for prime numbers is genuinely useful

  • Cryptography and computer science education — understanding primality testing is foundational to understanding how modern encryption actually works at a mathematical level.
  • Mathematical puzzles and recreational number theory — primes appear constantly in math puzzles, competition problems, and recreational mathematics exploration.
  • Programming and algorithm practice — implementing and understanding primality testing is a common introductory programming and algorithms exercise.
  • Verifying a specific number's properties — quickly confirming whether a number you've encountered (in a math problem, a puzzle, or just out of curiosity) is prime.

Frequently asked questions

Is 1 a prime number? No, by definition and mathematical convention — a prime number must have exactly two distinct positive divisors (1 and itself), while 1 has only one divisor (itself), which is why 1 is specifically excluded from the definition of prime, a convention mathematicians settled on partly because including 1 would break several important theorems about prime factorization.

Is 2 the only even prime number? Yes, and necessarily so — every even number greater than 2 is divisible by 2 in addition to itself and 1, meaning it automatically has at least three distinct divisors, disqualifying it from being prime; 2 is the sole exception, making it the only even prime.

Why do primes matter for internet security? Because RSA and related cryptographic systems rely on a genuine computational asymmetry: multiplying two large prime numbers together is fast and easy, but factoring that resulting large product back into its original two primes is, for sufficiently large primes, computationally infeasible with current technology — an asymmetry that makes encrypted communication practically secure.

Further reading