Prime Checker
Check if any number is prime using trial division. Find its prime factorization, count all divisors, and see step-by-step primality verification.
Enter a positive integer to check if it is prime
Results
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
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 Test — The positive integer being checked for primality. Must be at least 2.
- p
- Trial Divisor — Each integer we test as a possible divisor of n, starting from 2 and going up to the square root of n.
- d(n)
- Divisor Count — The 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 Division — The square root of n. If n has any divisor other than 1 and itself, at least one will be at or below sqrt(n).
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.
How to Use
- Enter any positive whole number from 1 up to 9,007,199,254,740,991 in the input field.
- The calculator instantly tells you whether the number is prime or composite.
- If the number is composite, view its complete list of prime factors separated by commas.
- See the divisor count to understand how many numbers divide the input evenly.
- Read the step-by-step primality check to understand exactly how the determination was made.
Quick Reference
| Smallest prime | 2 |
| Only even prime | 2 |
| First 5 primes | 2, 3, 5, 7, 11 |
| Composite example | 12 = 2 x 2 x 3 |
| Primes under 100 | 25 primes |
| Trial division limit | sqrt(n), e.g. odd divisors up to 3161 for n = 10 million |
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 the most recent GIMPS announcement we have verified, October 2024) is 2^136279841 - 1, a Mersenne prime found by the Great Internet Mersenne Prime Search (GIMPS) project. It has 41,024,320 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 — no known classical algorithm can factor a properly generated 2048-bit number in practical time.
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, √n ≈ 3162, so at most 1,580 odd divisors (3, 5, …, 3161) need to be checked, which is very fast. Above that, this calculator switches to the Miller–Rabin test.
- →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 stops at 9,007,199,254,740,991 (2⁵³ − 1). Prime generation for RSA keys (which uses 1024-bit or 2048-bit numbers) requires specialized big-number libraries.
Limitations to Know
- •Up to 10 million the steps list shows the trial divisions; above that the answer comes from the Miller–Rabin test, which is instant but is not shown division by division.
- •Numbers larger than 9,007,199,254,740,991 cannot be tested (a JavaScript number is no longer exact beyond that).
- •The primality test is deterministic (not probabilistic) for the whole supported range, but it does not produce 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.
Cite this calculator
TheCalcUniverse. "Prime Number Calculator — Check Primality & Find Factors." TheCalcUniverse, 2026, https://thecalcuniverse.com/math/prime-number/. Accessed October 25, 2026.
Embed this calculator on your site
You may also like
-
Mathematics
Factorial Calculator
Calculate the factorial of any number from 0 to 170. Shows the step-by-step multiplication, digit count, and trailing zeros.
Open calculator → -
Mathematics
Fibonacci Calculator
Calculate the nth Fibonacci number, view the full sequence, and get the sum. Uses iteration and the Binet formula for verification. Free, instant, and accurate.
Open calculator → -
Mathematics
Prime Factors
Break any integer into its unique prime factors with an interactive factor tree. Detects perfect squares, cubes, and handles numbers up to one million.
Open calculator → -
Mathematics
Factor Calculator
Find all factors of any positive integer with a complete factor pairs table, total factor count, sum of factors, and primality test.
Open calculator → -
Mathematics
LCM Calculator
Find the LCM of numbers or fractions, worked out step by step: listing multiples, prime factorization and the ladder (cake) method. Free LCM and GCF calculator.
Open calculator →