Skip to main contentSkip to secondary navigation

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.

✓ Formula verified: May 2026

Prime Checker

Enter values and click Calculate

Enter Values

The Formula

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

Variable Definitions

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

How to Use This Calculator

  1. 1

    Enter any positive integer between 1 and 10,000,000 in the input field.

  2. 2

    The calculator instantly tells you whether the number is prime or composite.

  3. 3

    If the number is composite, view its complete list of prime factors separated by commas.

  4. 4

    See the divisor count to understand how many numbers divide the input evenly.

  5. 5

    Read the step-by-step primality check to understand exactly how the determination was made.

Quick Reference

FromTo
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

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

1

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

2

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.

3

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.

4

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

5

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

n

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.

n

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

Related Calculators

Reviews

No reviews yet. Be the first to share your experience with Prime Number Calculator — Check Primality & Find Factors.

Write a Review

Your Rating *

0/1000

0/50

Medical Disclaimer: The health and fitness calculators on this site are for informational and educational purposes only. They are not a substitute for professional medical advice, diagnosis, or treatment. Always consult a qualified healthcare provider with any questions about your health.

Financial Disclaimer: The finance calculators on this site are for informational purposes only and do not constitute financial advice. Results are estimates based on the inputs provided and may vary. Consult a qualified financial advisor before making investment or financial decisions.

© 2026 TheCalcUniverse. All results are for informational purposes only.

Fast, free, and privacy-first.