What Are Prime Numbers?
Prime numbers have exactly two divisors: 1 and themselves.
The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29...
Primes are the building blocks of all integers.
Prime numbers are the fundamental building blocks of all integers and underpin modern cryptography, including RSA encryption that secures online banking and communications. This tool lets you check primality, decompose any number into its prime factors, and generate prime lists within a range using the Sieve of Eratosthenes algorithm. Practical uses range from simplifying fractions and computing LCM/GCD to understanding digital security and solving number theory problems in competitive programming.
Check primality, factorize, find next/previous prime, or list primes.
Input the number to check or use as starting point.
For prime lists, enter the end of range.
See if prime, factors, or prime list with steps.
A prime number has exactly two distinct positive divisors: 1 and itself. Testing divisibility up to √n is sufficient because factors come in pairs.
n is prime if its only divisors are 1 and n
2 is the only even prime number - all other even numbers are divisible by 2
1 is neither prime nor composite by definition
To check if n is prime, only test divisibility up to √n
Twin primes are pairs differing by 2: (3,5), (5,7), (11,13), (17,19)...
All primes > 3 are of form 6k±1 (but not all 6k±1 are prime)
Prime factorization is unique for every number (Fundamental Theorem of Arithmetic)
Check if a number is prime, find prime factors, generate prime lists, and discover next/previous primes. See step-by-step primality tests.
Prime numbers have exactly two divisors: 1 and themselves.
The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29...
Primes are the building blocks of all integers.
Every integer > 1 can be uniquely expressed as a product of primes.
For example, 60 = 2² × 3 × 5.
This is fundamental in mathematics and cryptography.
To check if a number n is prime, test whether any integer between 2 and the square root of n divides it evenly; if none does, n is prime.
First handle small cases:
Then test odd divisors up to √n, because divisors always come in pairs whose smaller member cannot exceed the square root.
For example, checking 97 only requires testing 3, 5, and 7 (since √97 ≈ 9.85), and none divide it, so 97 is prime. Wolfram MathWorld describes this as trial division, the most direct primality test.
The square root method means you only need to test potential divisors up to √n rather than all the way up to n.
The reason is that if n = a × b, then at least one of the factors a or b must be less than or equal to √n; otherwise their product would exceed n. So if no factor is found below √n, no larger factor exists either.
This dramatically reduces work: checking whether 9,973 is prime requires testing divisors only up to about 99, not nearly 10,000.
Khan Academy uses this pairing argument to explain why trial division stops at the square root, making manual primality checking practical.
The Sieve of Eratosthenes finds all primes up to a limit N by repeatedly marking the multiples of each prime as composite.
Start with a list of integers from 2 to N. Take 2, mark 4, 6, 8, ... as composite; move to the next unmarked number, 3, and mark 6, 9, 12, ...; continue with 5, 7, and so on. Numbers that remain unmarked are prime.
Applied up to 30, the sieve leaves 2, 3, 5, 7, 11, 13, 17, 19, 23, 29.
Named after the Greek mathematician Eratosthenes of Cyrene, this algorithm (documented by Encyclopaedia Britannica) is one of the oldest and most efficient ways to list primes in a range.
The Fundamental Theorem of Arithmetic states that every integer greater than 1 is either prime or can be written as a product of primes in exactly one way, apart from the order of the factors.
For example, 360 = 2³ × 3² × 5, and no other combination of primes multiplies to 360. This uniqueness is why primes are called the building blocks of the integers.
According to Wolfram MathWorld, this theorem underpins prime factorization, greatest common divisor computation, and modular arithmetic.
Our calculator uses it when it factors a number, guaranteeing the prime decomposition it returns is the only possible one.
Twin primes are pairs of primes that differ by exactly 2, such as (3, 5), (5, 7), (11, 13), (17, 19), and (29, 31).
The gap between consecutive primes generally grows as numbers get larger, though twin primes keep appearing. Whether infinitely many twin primes exist is the famous Twin Prime Conjecture, still unproven.
The On-Line Encyclopedia of Integer Sequences (OEIS) catalogs the lower members of twin prime pairs in sequence A001359.
Understanding prime gaps helps explain why primes become sparser: near one million, primes are spaced roughly 14 apart on average, a trend described by the Prime Number Theorem in the NIST Digital Library of Mathematical Functions.
Prime numbers power modern cryptography, especially RSA encryption, which secures online banking, HTTPS websites, and digital signatures. RSA relies on the fact that multiplying two large primes is easy, but factoring the product back into those primes is computationally hard.
Beyond security, primes appear in:
Britannica notes that prime factorization also simplifies fractions and computes least common multiples. This calculator supports these tasks by factoring numbers and generating primes for algorithm design and math homework alike.
A prime number has exactly two distinct positive divisors, 1 and itself, while a composite number has more than two divisors.
For example, 13 is prime (divisors 1 and 13), and 12 is composite (divisors 1, 2, 3, 4, 6, 12). The number 1 is neither prime nor composite, because it has only one divisor.
This convention keeps the Fundamental Theorem of Arithmetic clean: if 1 counted as prime, factorizations would no longer be unique since you could insert any number of 1s.
Encyclopaedia Britannica and Khan Academy both stress this distinction, which is why our tool labels 1 separately from primes and composites.
Mersenne primes are primes of the form 2^p − 1, where the exponent p is itself prime; examples include 3 (2² − 1), 7 (2³ − 1), 31 (2⁵ − 1), and 127 (2⁷ − 1).
Not every prime exponent yields a prime, however: 2¹¹ − 1 = 2047 = 23 × 89 is composite.
Mersenne primes matter because a fast test called the Lucas-Lehmer test makes them easier to verify than arbitrary numbers, so the largest known primes are almost always Mersenne primes with tens of millions of digits.
The Great Internet Mersenne Prime Search (GIMPS) coordinates volunteers to discover them. OEIS sequence A000668 lists known Mersenne primes.
Data sourced from trusted institutions
All formulas verified against official standards.