Prime Number Checker

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.

star 4.8

Prime Number Checker calculator

tag Prime Number Checker
First 25 Primes
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
Key Facts
• 2 is the only even prime
• 1 is neither prime nor composite
• Check divisibility up to √n
check_circle Result
97 is PRIME
The 25th prime number
Previous Prime
89
Next Prime
101
Divisibility Test
√97 ≈ 9.85, check up to 9
97 ÷ 2 = 48.5 (not divisible)
97 ÷ 3 = 32.33 (not divisible)
97 ÷ 5 = 19.4 (not divisible)
97 ÷ 7 = 13.86 (not divisible)
→ No divisors found, 97 is prime

lightbulb Tips

  • 2 is the only even prime number
  • 1 is neither prime nor composite
  • Check divisors only up to √n
  • All primes > 3 are of form 6k±1

table_chart First 100 Primes

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541
Prime Facts
Primes ≤ 100: 25
Primes ≤ 1000: 168
Twin primes: (3,5), (5,7), (11,13), (17,19)...

How to Use the Prime Number Checker

calculate

Choose Check Type

Check primality, factorize, find next/previous prime, or list primes.

edit

Enter Number

Input the number to check or use as starting point.

tune

Set Range (if needed)

For prime lists, enter the end of range.

visibility

View Results

See if prime, factors, or prime list with steps.

The Formula

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

lightbulb Variables Explained

  • Prime Number with exactly 2 divisors: 1 and itself
  • Composite Number with more than 2 divisors
  • √n Only need to check divisors up to square root

tips_and_updates Pro Tips

1

2 is the only even prime number - all other even numbers are divisible by 2

2

1 is neither prime nor composite by definition

3

To check if n is prime, only test divisibility up to √n

4

Twin primes are pairs differing by 2: (3,5), (5,7), (11,13), (17,19)...

5

All primes > 3 are of form 6k±1 (but not all 6k±1 are prime)

6

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.

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 Factorization

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.

How Do You Check If a Number Is Prime?

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:

  • numbers below 2 are not prime
  • 2 and 3 are prime
  • any even number above 2 is composite

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.

What Is the Square Root Method for Testing Primality?

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.

How Does the Sieve of Eratosthenes Generate Primes?

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.

What Is the Fundamental Theorem of Arithmetic?

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.

What Are Twin Primes and Prime Gaps?

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.

What Are the Real-World Uses of Prime Numbers?

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:

  • hash table sizing (prime-length tables reduce collisions)
  • pseudo-random number generation
  • error-correcting codes
  • cicada life cycles that evolved around prime-numbered years to avoid predators

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.

What Is the Difference Between Prime, Composite, and the Number 1?

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.

What Are Mersenne Primes and How Large Can Primes Get?

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.

Common Mistakes When Working With Prime Numbers

  • The most common mistake is treating 1 as prime; it is not, because a prime must have exactly two divisors.
  • Another error is forgetting that 2 is the only even prime, so people wrongly skip it or wrongly assume other even numbers might be prime.
  • A third mistake is stopping trial division too early or too late: you must test all divisors up to √n, not just a few small ones.
  • People also confuse prime factorization with listing all factors; 12 has factors 1, 2, 3, 4, 6, 12 but a prime factorization of only 2² × 3.
  • Finally, assuming every number of the form 6k ± 1 is prime is false; 25 = 6(4) + 1 is composite.

Frequently Asked Questions

sell

Tags