Prime Number Calculator

A prime number is a positive whole number greater than 1 that has only two factors: 1 and itself. A whole number greater than 1 with more than two factors is a composite number. Enter any positive whole number up to 5,000 digits into the calculator above to check if it is prime or composite. You will receive the primality status, the complete list of factors, the prime factorization, and the nearest prime numbers.

Test a number
Results update as you type

2 digits

Verdict
Proven
97
Prime

Its only positive divisors are 1 and itself.

Method
Trial division and Miller-Rabin
Digits
2
Prime index
the 25th prime

Nearest primes

Previous prime
89
gap of 8
Next prime
101
gap of 4
Portrait of Ethan Park

Created by Ethan Park

Last updated: September 28, 2026

What Is a Prime Number?

A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. If you divide a prime number by any whole number other than 1 and itself, you will always get a remainder.

For example, 7 is a prime number because its only whole-number factors are 1 and 7. By contrast, 8 is a composite number because it can be divided evenly by 1, 2, 4, and 8.

The number 1 is neither prime nor composite. It has only one factor (itself), which fails the definition requiring exactly two distinct positive factors.

List of First 25 Prime Numbers

The first 25 prime numbers (all primes under 100) are:

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

The number 2 is the only even prime number. Every other even number can be divided by 2, which makes all larger even numbers composite.

How to Test if a Number Is Prime

You can test if a number is prime using two standard methods.

1. The Square Root Trial Division Method

You do not need to test every single number up to your target integer. You only need to test prime numbers up to the square root of your target.

  1. Find the square root of your test number (โˆšn).
  2. List all prime numbers less than or equal to that square root.
  3. Divide your test number by each prime on that list.
  4. If none of these primes divide your number evenly, the number is prime. If any prime divides it without a remainder, the number is composite.

Example: Check if 149 is prime.

  1. Calculate the square root: โˆš149 โ‰ˆ 12.2.
  2. List primes up to 12.2: 2, 3, 5, 7, 11.
  3. Divide 149 by each prime: 149 รท 2 = 74.5, 149 รท 3 = 49.66, 149 รท 5 = 29.8, 149 รท 7 = 21.28, 149 รท 11 = 13.54.
  4. None divide evenly, so 149 is a prime number.

For larger composite numbers, finding all prime factors can be simplified using a prime factorization calculator.

2. Sieve of Eratosthenes (Finding All Primes up to a Limit)

To find all prime numbers up to a specific limit n, the Sieve of Eratosthenes is an efficient manual method:

  1. Write out all whole numbers from 2 to your chosen limit n.
  2. Start with 2. Circle 2, then cross out all multiples of 2 (4, 6, 8, 10, etc.).
  3. Move to the next uncrossed number, which is 3. Circle 3, then cross out all multiples of 3.
  4. Repeat this process for the next uncrossed number (5, then 7, and so on).
  5. Continue until you reach the square root of n. All remaining uncrossed numbers on your list are prime.

If you need to analyze the common factors between two integers generated from prime lists, a greatest common factor calculator can process those sets instantly.

Prime Numbers vs. Composite Numbers

Understanding the difference between prime and composite numbers depends on factor counts.

FeaturePrime NumbersComposite Numbers
Number of FactorsExactly 2 (1 and itself)3 or more
DivisibilityDivisible only by 1 and itselfDivisible by other integers
Smallest Example2 (the only even prime)4
Examples2, 3, 5, 7, 11, 13, 174, 6, 8, 9, 10, 12, 14

Numbers that share no common factors other than 1 are known as coprimes. You can check whether a pair of numbers is coprime by comparing their greatest common factor: if it equals 1, the numbers share no common divisors.

Real-World Applications of Prime Numbers

Prime numbers serve practical roles in technology, science, and nature.

  • Computer Cryptography: Modern web encryption relies on prime numbers. Algorithms like RSA create secure encryption keys by multiplying two very large prime numbers. Decoding the message requires factoring that huge product back into its original primes, a task that takes classical supercomputers years to calculate.
  • Hash Functions: Computer databases use prime numbers in hashing algorithms to distribute data evenly across memory storage and avoid data collisions.
  • Cicada Life Cycles: Certain species of periodic cicadas emerge from underground only every 13 or 17 years. These prime-numbered year cycles make it difficult for predators to sync their own population spikes with the cicadas' appearance.

Frequently Asked Questions

Why is 1 not a prime number?

1 is not a prime number because a prime number must have exactly two distinct positive factors: 1 and itself. The number 1 has only one factor (1). Excluding 1 keeps the Fundamental Theorem of Arithmetic consistent, which states that every whole number greater than 1 has a single unique prime factorization.

Is 0 a prime number?

No, 0 is not a prime number. Prime numbers must be positive integers greater than 1. Zero has infinitely many factors because any non-zero number multiplied by 0 equals 0.

What is the largest known prime number?

As of recent mathematical searches, the largest known prime number is 2^136,279,841 - 1. This Mersenne prime has 41,024,320 decimal digits.

Is 2 the only even prime number?

Yes, 2 is the only even prime number. Every larger even number can be divided by 2, which gives it at least three factors (1, 2, and itself) and makes it composite.

What is a Mersenne prime?

A Mersenne prime is a prime number that can be written in the form 2^p - 1, where p is also a prime number. For example, 7 is a Mersenne prime because 2^3 - 1 = 7.

Related Calculators