# Prime Number Checker

> Free prime number checker — instantly test if a number is prime, find prime factors, list primes in a range, and find the next & previous prime, with steps.

**URL:** https://calculators.im/prime-number-calculator  
**Category:** math  
**Last updated:** 2026-07-03  

Check if a number is prime, find prime factors, generate prime numbers in a range, and discover the next or previous prime. Get step-by-step primality tests.

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.

## Formula

```
n is prime if its only divisors are 1 and n
```

**Variables:**

- **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

A prime number has exactly two distinct positive divisors: 1 and itself. Testing divisibility up to √n is sufficient because factors come in pairs.

## Worked Example

### Check if 97 is Prime

97 is prime because it has no divisors other than 1 and itself. We only need to check divisibility up to √97 ≈ 9, and none of 3, 5, 7, or 9 divide 97 evenly.

## How to Use the Prime Number Checker

1. **Choose Check Type** — Check primality, factorize, find next/previous prime, or list primes.
2. **Enter Number** — Input the number to check or use as starting point.
3. **Set Range (if needed)** — For prime lists, enter the end of range.
4. **View Results** — See if prime, factors, or prime list with steps.

## Pro Tips

- 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)

## Frequently Asked Questions

### What is a prime number?

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 2, 3, 5, 7, 11, 13 are prime numbers. The number 1 is not considered prime.

### How do you check if a number is prime?

To check if n is prime: 1) If n < 2, it's not prime. 2) If n is 2, it's prime. 3) If n is even and > 2, it's not prime. 4) Check divisibility by odd numbers from 3 up to √n. If no divisor is found, n is prime.

### What is prime factorization?

Prime factorization is expressing a number as a product of its prime factors. For example, 60 = 2² × 3 × 5. Every integer greater than 1 has a unique prime factorization (Fundamental Theorem of Arithmetic).

### What is the difference between prime and composite numbers?

Prime numbers have exactly two factors: 1 and themselves. Composite numbers have more than two factors. For example, 7 is prime (factors: 1, 7), while 6 is composite (factors: 1, 2, 3, 6). The number 1 is neither prime nor composite.

### Why is 2 the only even prime number?

2 is the only even prime because every other even number is divisible by 2, giving it at least three factors (1, 2, and itself). Since 2 only has factors 1 and 2, it's prime. This makes 2 unique among primes.

### What is the largest known prime number?

The largest known prime numbers are Mersenne primes (2^p - 1). As of 2024, the largest known prime is 2^82,589,933 - 1, which has over 24 million digits. Finding large primes is important for cryptography.

## Deep Dive

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.

## Related Calculators

- [factorial-calculator](https://calculators.im/factorial-calculator)
- [fibonacci-calculator](https://calculators.im/fibonacci-calculator)
- [lcm-gcd-calculator](https://calculators.im/lcm-gcd-calculator)
- [base-converter](https://calculators.im/base-converter)
- [logarithm-calculator](https://calculators.im/logarithm-calculator)
- [modulo-calculator](https://calculators.im/modulo-calculator)

## Authoritative Sources

- [Wolfram MathWorld — Prime Number](https://mathworld.wolfram.com/PrimeNumber.html) — Comprehensive reference on primes, trial division, and the Fundamental Theorem of Arithmetic.
- [NIST Digital Library of Mathematical Functions (DLMF) — Number Theory](https://dlmf.nist.gov/27) — Authoritative reference including the Prime Number Theorem and distribution of primes.
- [OEIS A001359 — Twin Primes](https://oeis.org/A001359) — On-Line Encyclopedia of Integer Sequences entry for lower members of twin prime pairs.
- [OEIS A000668 — Mersenne Primes](https://oeis.org/A000668) — On-Line Encyclopedia of Integer Sequences catalog of known Mersenne primes.
- [Khan Academy — Prime Numbers](https://www.khanacademy.org/math/cc-fourth-grade-math/factors-multiples/imp-prime-numbers/a/prime-numbers) — Introductory lessons on prime versus composite numbers and primality testing.
- [Encyclopaedia Britannica — Prime](https://www.britannica.com/science/prime-number) — Encyclopedia overview of prime numbers, the Sieve of Eratosthenes, and their significance.

---

*Source: https://calculators.im/prime-number-calculator — calculators.im, 299+ free online calculators.*
