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.
Prime Checker
Enter values and click Calculate
Enter Values
Embed Code
Copy and paste this HTML snippet into any web page to embed this calculator directly.
<iframe src="http://127.0.0.1:59362/embed/math/prime-number?ref=embed" title="Prime Number Calculator — Check Primality & Find Factors" width="100%" style="max-width:600px; border:none; height:500px;" loading="lazy"></iframe>
Direct Link
Share this link to let others open the calculator in their browser.
The Formula
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).
Variable Definitions
Number to Test
The positive integer being checked for primality. Must be at least 2.
Trial Divisor
Each integer we test as a possible divisor of n, starting from 2 and going up to the square root of n.
Divisor Count
The total number of positive integers that divide n evenly, including 1 and n. A prime has exactly 2 divisors.
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).
How to Use This Calculator
- 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
| From | To |
|---|---|
| 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), check up to 3162 for 10M |
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.
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.
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).
97
Result:
Insight: 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.
1000003
Result:
Insight: 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.
Limitations
- The trial division algorithm becomes computationally expensive for numbers near the 10 million upper bound, though still well 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.
Frequently Asked Questions
Sources & References
Related Calculators
Reviews
No reviews yet. Be the first to share your experience with Prime Number Calculator — Check Primality & Find Factors.
Write a Review
