Math
Prime Number Calculator
Enter a number to find out if it is prime.
Small numbers are checked by trial division with every tested prime listed; large numbers up to 24 digits use a deterministic Miller–Rabin test, so the verdict is exact, not probabilistic. Composite numbers get their prime factorization, and every result includes the next and previous primes. Switch to range mode to list all primes between two numbers.
A whole number up to 24 digits. Exact big-integer arithmetic; no rounding.
Try an example
Result
Verdict
—
- Prime factorization
- —
- Next prime
- —
- Previous prime
- —
- Primes found
- —
Student quick launch
Grade planning, algebra checks, and formulas students reach for most.
Study path
Use this calculator with
Follow these when you want the formula behind the answer, a short lesson, or nearby tools in the same topic.
What the prime number calculator solves
Enter a number to find out if it is A whole number above 1 whose only factors are 1 and itself.. Small numbers are checked by trial division with every tested prime listed; large numbers up to 24 digits use a deterministic Miller–Rabin test, so the verdict is exact, not probabilistic. Composite numbers get their prime factorization, and every result includes the next and previous primes. Switch to range mode to list all primes between two numbers.
Formula
How to use it
- Choose Is this number prime? and type the number, or choose List primes in a range and enter the endpoints.
- Read the verdict. Composite numbers show their prime factorization; primes show the nearest primes on either side.
- Open the steps to see which primes were tested, or the sieve output and twin primes for a range.
How to read the answer
A verdict of prime means nothing divides the number except 1 and itself. Composite means at least one smaller prime divides it; the factorization lists them all. Neither 0 nor 1 is prime: 1 has only one divisor and 0 has infinitely many. The nearest primes help when a problem asks for the next or previous prime.
Common mistakes and edge cases
- Calling 1 a prime. Primes need exactly two divisors; 1 has one.
- Assuming every odd number is prime: 9, 15, 21, and 91 = 7 × 13 are odd and composite.
- Testing divisors all the way up to n. Only primes up to √n are needed: for 97 that means 2, 3, 5, and 7.
- Trusting a single Fermat test. 561 = 3 × 11 × 17 passes Fermat's test for every base coprime to it; Miller–Rabin catches it.
- Forgetting 2 is prime, the only even one.
Worked examples
97 is prime
Only 2, 3, 5, and 7 need testing.
Verdict
97 is prime
91 looks prime but is not
91 = 7 × 13.
Verdict
91 is composite (not prime)
Large prime 1,000,000,007
A common programming modulus.
Verdict
1,000,000,007 is prime
20-digit prime
The largest 64-bit prime, verified by Miller–Rabin.
Verdict
18,446,744,073,709,551,557 is prime
1 is not prime
Exactly one divisor.
Verdict
1 is neither prime nor composite
Primes from 1 to 100
There are 25 of them.
Verdict
25 primes between 1 and 100
Bad input
Decimals are not tested.
Verdict
Error
Frequently asked questions
Is 1 a prime number?+
No. A prime must have exactly two positive divisors, 1 and itself. The number 1 has only one divisor, so it is neither prime nor composite.
How do you check if a number is prime by hand?+
Divide by each prime up to its square root. For 97, √97 ≈ 9.8, so test 2, 3, 5, and 7. None divide 97, so it is prime.
Is 2 a prime number?+
Yes, and it is the only even prime. Every other even number is divisible by 2 and therefore composite.
How does the calculator test very large numbers?+
With the Miller–Rabin test using the first twelve prime bases. That combination is proven exact for every number below 3.3 × 10^24, so a 24-digit verdict is certain, not probabilistic.
How many primes are there between 1 and 100?+
25: 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.
What are twin primes?+
Two primes that differ by 2, such as 11 and 13 or 101 and 103. The range mode lists every twin-prime pair it finds.
Is 0 prime?+
No. Every integer divides 0, so it has infinitely many divisors and cannot be prime.
About this calculator
- Written by
- mathcheck editorial team
- Last reviewed
- September 4, 2026
Method
- Uses the values entered by the user and stable formulas documented on the page.
Related calculators
Prime Factorization Calculator
Factor a positive integer into primes and show the factor tree style division steps.
Factor Calculator
Find all factors of a whole number, the factor pairs, how many divisors it has and their sum, the prime factorization, and whether the number is prime, perfect, abundant, or deficient.
Divisibility Test Calculator
Test any whole number against the divisibility rules for 2 through 13 with the actual rule work shown (digit sums, last digits, the 7 and 13 chop tricks), plus a custom divisor with quotient and remainder.
GCF and LCM Calculator
Find the greatest common factor and least common multiple for a list of positive integers with factor steps.
Complex Number Calculator
Add, subtract, multiply, divide, and raise complex numbers to powers exactly. Shows the modulus, argument in degrees and radians (with exact π fractions), conjugate, polar and exponential forms, De Moivre's theorem, and the point on the complex plane.
Graphing Inequalities on a Number Line Calculator
Graph one inequality or a compound 'and'/'or' inequality on a number line with open and closed dots, and get the solution in inequality, interval, and set-builder notation. Shows each part of a compound inequality on its own line before combining.
Last updated: September 4, 2026