Skip to content
TheCalcUniverse

Prime Number Calculator — Check Primality & Find Factors

Check if any number is prime using trial division. Find its prime factorization, count all divisors, and see step-by-step primality verification.

✓ Tested formula & cited sources Formula verified 2026-05-17 Runs in your browser — inputs never sent anywhere

See it worked out

Example — Number 97:

Is Prime

Yes

Prime Factors

97 (prime)

Number of Divisors

2

Primality Check Steps

Checking divisibility of 97 by odd numbers from 3 up to √97 = 9: No divisors found up to 9. Therefore, 97 is prime.

The formula

n is prime iff it has exactly two distinct positive divisors: 1 and itself

n
Number to Test
p
Trial Divisor
d(n)
Divisor Count
sqrt(n)
Upper Bound for Trial Division

Worked example — Number 97

Is Prime = Yes

Full explanation ↓

How Prime Checker Works

n is prime iff it has exactly two distinct positive divisors: 1 and itself

A prime number is a positive integer greater than 1 that has no positive divisors other than 1 and itself. To check primality, we use trial division: test whether n is divisible by any integer from 2 up to the square root of n. If none divide evenly, n is prime. This method works because if n has a divisor d greater than sqrt(n), then n/d would be a divisor smaller than sqrt(n), so we only need to check up to sqrt(n).

n
Number to TestThe positive integer being checked for primality. Must be at least 2.
p
Trial DivisorEach integer we test as a possible divisor of n, starting from 2 and going up to the square root of n.
d(n)
Divisor CountThe total number of positive integers that divide n evenly, including 1 and n. A prime has exactly 2 divisors.
sqrt(n)
Upper Bound for Trial DivisionThe square root of n. If n has any divisor other than 1 and itself, at least one will be at or below sqrt(n).
Prime number distribution from 1 to 100. Primes are shown in green. There are 25 primes in the first 100 numbers, illustrating that primes become sparser as numbers increase.

How to Use

  1. Enter any positive integer between 1 and 10,000,000 in the input field.
  2. The calculator instantly tells you whether the number is prime or composite.
  3. If the number is composite, view its complete list of prime factors separated by commas.
  4. See the divisor count to understand how many numbers divide the input evenly.
  5. Read the step-by-step primality check to understand exactly how the determination was made.

Quick Reference

Smallest prime2
Only even prime2
First 5 primes2, 3, 5, 7, 11
Composite example12 = 2 x 2 x 3
Primes under 10025 primes
Trial division limitsqrt(n), check up to 3162 for 10M

Worked Examples

Maria is teaching her 6th-grade class about prime factorization. She wants to check if 97 is prime to demonstrate that not all numbers in the 90s are composite (90, 91, 92, 93, 94, 95, 96 are all composite).

n = 97

97 IS prime. Divisors: 2 (1 and 97). sqrt(97) = 9.8, checked odd numbers 3, 5, 7, 9 — no divisors found.

Testing 97: sqrt(97) = 9.8, so we check divisibility by odd numbers 3, 5, 7, 9. 97/3 = 32.33 (not integer), 97/5 = 19.4, 97/7 = 13.857, 97/9 = 10.778. No divisors found, so 97 is prime. It is the largest prime under 100 and a member of the Pythagorean triple (65, 72, 97). Its prime factorization is just 97 itself.

A computer science student needs to verify that 1,000,003 is prime for a hashing algorithm assignment. They recall that primes of the form 10^6 + 3 sometimes produce good hash table sizes.

n = 1000003

1,000,003 IS prime. Divisors: 2 (1 and itself). sqrt(1000003) = 1000, checked all odd numbers up to 999 — no divisors found. Suitable for hash table sizing.

The trial division algorithm checks all potential divisors up to sqrt(1000003) = 1000. After checking all odd numbers from 3 to 999 and finding no divisor, the calculator confirms 1,000,003 IS prime. This makes it suitable for a hash table size as it minimizes collision patterns. The number has exactly 2 divisors: 1 and itself.

Frequently Asked Questions

Is 1 a prime number?
No, 1 is not a prime number. By definition, a prime number must have exactly two distinct positive divisors. The number 1 has only one divisor (itself). Excluding 1 from the primes ensures the Fundamental Theorem of Arithmetic holds: every integer has a unique prime factorization. If 1 were considered prime, factorizations would no longer be unique (e.g., 6 = 2 × 3 = 1 × 2 × 3 = 1 × 1 × 2 × 3, etc.).
What is the largest known prime number?
The largest known prime as of early 2025 is 2^136279841 - 1, a Mersenne prime discovered by the Great Internet Mersenne Prime Search (GIMPS) project. It has over 41 million digits. Mersenne primes are of the form 2^p - 1 and are easier to test for primality using the Lucas-Lehmer test. New ones are discovered regularly by distributed computing projects.
What is the difference between a prime and a composite number?
A prime number has exactly two factors: 1 and itself. A composite number has more than two factors — it can be divided evenly by numbers other than 1 and itself. For example, 7 is prime (only 1 and 7 divide it), while 12 is composite (it can be divided by 1, 2, 3, 4, 6, and 12). Every integer greater than 1 is either prime or composite.
How does trial division work for primality testing?
Trial division tests whether n is divisible by any integer d from 2 up to sqrt(n). If n is divisible by any d in this range, then n is composite (we have found a divisor). If no d divides n, then n is prime. We only need to go up to sqrt(n) because if n = a × b and both a and b are greater than sqrt(n), then a × b > n, which is impossible. So at least one factor must be at or below sqrt(n).
How do prime numbers relate to cryptography?
RSA encryption, one of the most widely used encryption systems, relies on the fact that multiplying two large primes together is easy, but factoring the result back into primes is extremely hard. A typical RSA key uses two primes that are each hundreds of digits long. The security of the system depends on this asymmetry — even with the fastest computers, factoring a 2048-bit number into its prime factors would take longer than the age of the universe with current algorithms.

Pro Tips

  • All primes greater than 3 are of the form 6k+1 or 6k-1. Use this fact to quickly spot likely primes: a number not fitting either form cannot be prime (except 2 and 3).
  • Numbers ending in 0, 2, 4, 6, or 8 (even numbers > 2) and numbers ending in 5 (> 5) are always composite — you do not need a calculator for these.
  • If you are testing many numbers, remember that the trial division algorithm checks up to sqrt(n). For n = 10,000,000, this means at most 1,581 odd numbers need to be checked, which is very fast.
  • The divisor count result is especially useful: a prime has exactly 2 divisors, a prime power p^k has k+1 divisors, and composite numbers with many small prime factors can have surprisingly many divisors (e.g., 720 has 30 divisors).
  • For cryptographic or large-number use cases, note that this calculator is limited to 10 million. Prime generation for RSA keys (which uses 1024-bit or 2048-bit numbers) requires specialized libraries and probabilistic primality tests.

Limitations to Know

  • The trial division algorithm becomes computationally expensive for numbers near the 10 million upper bound, though still within practical limits (sqrt(10M) = 3162 divisions).
  • Numbers larger than 10 million cannot be tested with this calculator.
  • The primality test is deterministic for the supported range but does not provide a certificate of primality suitable for cryptographic verification.
  • The prime factorization shown for composite numbers may not be unique in its display format, though the fundamental theorem of arithmetic guarantees uniqueness of the factor set.
Was this calculator helpful?
Cite this calculator

TheCalcUniverse. "Prime Number Calculator — Check Primality & Find Factors." TheCalcUniverse, 2026, https://thecalcuniverse.com/math/prime-number/. Accessed July 24, 2026.

Embed this calculator on your site

Free to embed. Paste this into any HTML page — it stays up to date automatically.

Open embed ↗

You may also like

Guides that use this calculator