Prime Number Calculator
Check whether a whole number is prime, see why, and explore related prime tools.
✓ 97 is 100% Prime: no numbers divide into it evenly up to √97 — Has only 2 factors: 1 and itself
Show step-by-step division checks
To check if a number is prime, you do not need to test every smaller number. You only need to test prime numbers up to its square root.
How Our Prime Number Calculator Works
Built for speed, accuracy, and clear step-by-step explanations.
Interactive 3-Step Process
Click any step to see what happens:Enter a Whole Number
Type any positive whole number into the box or pick one of our example numbers above.
Click Check Prime
The calculator checks if any smaller number divides into it evenly, using fast and proven math checks.
Read Your Result
See whether your number is prime or composite, with step-by-step division checks, prime factors, and nearby primes.
Prime Number Tools
Easy-to-use calculators built to help you explore and solve prime number math.
Prime Generator
Create full lists of prime numbers in any range you choose, and easily copy the results.
Use Tool →Prime Factorisation
Break down composite numbers into their prime factors using simple step-by-step division ladders and factor trees.
Use Tool →Next & Previous Prime
Find the closest prime numbers just above and below your number, and see how far away they are.
Use Tool →Nth Prime
Find any prime by its exact position in the sequence, from the 1st prime (2) to the 10,000th prime (104,729).
Use Tool →Prime Sum
Add up all the prime numbers in any range you choose, with 100% exact math.
Use Tool →Primes Between
Find and count all the prime numbers between any two numbers, and see the gaps between them.
Use Tool →Coprime Checker
Check if two numbers share any common factors besides 1, with clear step-by-step division.
Use Tool →Prime Counting π(x)
See how many primes exist up to any number, and discover how prime numbers thin out as numbers get bigger.
Use Tool →1–100 Prime Chart
Interactive 10×10 visual grid that shows how to find primes step by step, with a printable option.
Use Tool →Factor Tree Calculator
Interactive visual factor tree. Watch numbers branch step by step into their prime factors.
Use Tool →Twin Prime Calculator
Find twin prime pairs (primes that differ by just 2, like 11 and 13) and see how often they appear.
Use Tool →Prime Gap Calculator
Find the distances between back-to-back prime numbers and spot large gaps.
Use Tool →Sieve of Eratosthenes
Interactive animated visualizer crossing off multiples step by step to reveal prime numbers.
Use Tool →Bulk Prime Checker
Check up to 500 numbers at the same time to see which are prime and export to CSV.
Use Tool →Random Prime Generator
Generate truly random prime numbers with custom digit lengths.
Use Tool →Prime Number Theorem
Compare the exact count of prime numbers against famous mathematical estimation formulas.
Use Tool →Goldbach Calculator
Find pairs of prime numbers that add up to any even number you choose.
Use Tool →Semiprime Calculator
Analyze numbers made by multiplying exactly two prime numbers together (like 15 = 3 × 5).
Use Tool →Mersenne Prime Calculator
Test huge primes written as 2^p - 1 and explore world-record prime numbers.
Use Tool →Prime Power Calculator
Test if a number is a prime raised to a power (like 2³ = 8 or 3² = 9).
Use Tool →Special Prime Checker
Explore fascinating prime families like palindrome primes, twin primes, and mirror primes.
Use Tool →Prime Distribution & Ulam Spiral
View prime numbers plotted on a visual 2D spiral to discover line patterns.
Use Tool →RSA Prime Demo
Interactive visual demonstration of how prime numbers lock and protect secret messages online.
Use Tool →Fraction Prime Factorization
Break down fractions into prime factors and simplify them easily.
Use Tool →How to Check If a Number Is Prime
Simple algorithms and copyable code examples in Python, JavaScript, C++, Java, and Go.
Use Tool →What Is a Prime Number?
The basic building blocks of all numbers.
Interactive Visual: The Rectangle Test
A number is prime if you can only arrange its dots into a single straight line. If you can arrange them into a neat rectangle with two or more rows, it is composite.
Definition and Examples
In math, a prime number is a positive whole number greater than 1 that has only two factors: 1 and itself. This means no other numbers divide into it evenly.
The first ten prime numbers are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29.
Every whole number greater than 1 that is not prime is called a composite number, because it can be made by multiplying smaller prime numbers together.
Why 0 and 1 Are Not Prime
0 is neither prime nor composite: It can be divided by any number without a remainder (0 ÷ 5 = 0), so it has endless factors. Also, prime numbers must be positive numbers greater than 1.
1 is neither prime nor composite: It has only one factor (itself). If 1 were counted as prime, every number could be broken down in endless different ways (such as 6 = 2 × 3 = 1 × 2 × 3 = 1 × 1 × 2 × 3), which would break the basic rules of arithmetic.
Classification map of whole numbers: 0 (zero divisors rule), 1 (unit), Primes (2 factors), and Composites (3+ factors).
Prime vs. Composite Numbers
A quick look at the simple differences between prime and composite numbers:
| Feature | Prime Numbers | Composite Numbers |
|---|---|---|
| Definition | Has only 2 factors: 1 and itself | Has more than 2 factors |
| Number of Factors | Exactly 2 factors | 3 or more factors |
| Smallest Example | 2 (the only even prime) | 4 (2 × 2) |
| Prime Factors | Just the number itself (p¹) | Multiplied from prime factors (like 12 = 2² × 3) |
| Even Numbers | Only 2 is prime; all other even numbers are composite | All even numbers greater than 2 (4, 6, 8, 10, 12…) |
| Examples | 2, 3, 5, 7, 11, 13, 97, 101 | 4, 6, 8, 9, 12, 51, 91, 100 |
Why 2 Is the Only Even Prime
An even number is any number you can divide by 2. The number 2 only has two factors (1 and 2), which makes it prime. But every larger even number can be divided by 1, 2, and itself, giving it at least three factors. Because it has extra factors, no even number greater than 2 can ever be prime.
Are 7 and 9 Prime Numbers?
7 is a prime number: Its only factors are 1 and 7. No other numbers multiply to 7. 9 is NOT a prime number: 9 can be divided evenly by 3 (3 × 3 = 9). It has three factors: 1, 3, and 9. Just because a number is odd does not mean it is prime!
How to Check if a Number Is Prime
The square root shortcut and step-by-step methods.
Interactive Tool: The Square Root Shortcut
See how testing only up to the square root saves huge amounts of time when checking for prime numbers.
Division Checks up to √n
The Square Root Shortcut
To check if a number is prime, you do not need to test every smaller number. You only need to test prime numbers up to its square root.
Why this works: Factors always come in pairs (a × b = n). If both factors were bigger than the square root, multiplying them would make a number larger than n. So if a number has any factors, at least one of them must be equal to or smaller than its square root.
Worked Example: Is 97 Prime?
- Find √97 ≈ 9.8. We only need to test prime numbers up to 9.
- The primes to test are: 2, 3, 5, and 7.
- 97 ÷ 2 = 48 remainder 1 (Does not divide evenly, ends in odd digit 7).
- 97 ÷ 3 = 32 remainder 1 (Does not divide evenly, digits 9+7=16 is not divisible by 3).
- 97 ÷ 5 = 19 remainder 2 (Does not divide evenly, does not end in 0 or 5).
- 97 ÷ 7 = 13 remainder 6 (Does not divide evenly).
- None of the primes up to √97 divided into 97 evenly. Therefore, 97 is 100% prime!
Worked Example: Why Is 91 Composite?
- Find √91 ≈ 9.5. We only need to test prime numbers up to 9.
- The primes to test are: 2, 3, 5, and 7.
- 91 ÷ 2 = 45 remainder 1 (Does not divide evenly).
- 91 ÷ 3 = 30 remainder 1 (Does not divide evenly, digits 9+1=10).
- 91 ÷ 5 = 18 remainder 1 (Does not divide evenly, does not end in 0 or 5).
- 91 ÷ 7 = 13 remainder 0 (Divides evenly!).
- Since 7 divides into 91 evenly, 91 is a composite number: 91 = 7 × 13.
Mental Math Shortcuts
You can quickly spot composite numbers in your head using these simple rules:
- Divisible by 2: The last digit is even (0, 2, 4, 6, 8).
- Divisible by 3: The digits add up to a multiple of 3 (for example, for 51: 5+1=6, so 51 ÷ 3 = 17).
- Divisible by 5: The last digit is 0 or 5.
- The 6k ± 1 rule: Every prime number greater than 3 is either 1 less or 1 more than a multiple of 6 (like 5, 7, 11, 13, 17, 19). If a number isn't next to a multiple of 6, it cannot be prime!
Divisibility Rules & Shortcuts
Simple mental rules to quickly tell if a number can be divided evenly without using a calculator.
Interactive Visual: The Multiple-of-6 Rule
Every prime number greater than 3 is always next to a multiple of 6 (either one less or one more).
| Number | Rule to Check | Example | Live Result |
|---|---|---|---|
| 2 | The last digit is even: 0, 2, 4, 6, or 8. | 248 ends in 8 → Divisible by 2 | |
| 3 | The sum of all individual digits can be divided by 3. | 453 → 4+5+3 = 12 (divisible by 3) → Divisible by 3 | |
| 4 | The number formed by the last two digits can be divided by 4. | 3,116 ends in 16 (16 ÷ 4 = 4) → Divisible by 4 | |
| 5 | The last digit is either 0 or 5. | 895 ends in 5 → Divisible by 5 | |
| 6 | The number passes both the 2 test (even) and the 3 test (digits add to a multiple of 3). | 732 is even and 7+3+2 = 12 → Divisible by 6 | |
| 7 | Double the last digit and subtract it from the rest. The result divides by 7. | 672 → 67 − (2×2) = 63 (63 ÷ 7 = 9) → Divisible by 7 | |
| 8 | The number formed by the last three digits can be divided by 8. | 5,128 ends in 128 (128 ÷ 8 = 16) → Divisible by 8 | |
| 9 | The sum of all individual digits can be divided by 9. | 2,871 → 2+8+7+1 = 18 (18 ÷ 9 = 2) → Divisible by 9 | |
| 11 | The alternating sum of digits (add-subtract-add...) is 0 or a multiple of 11. | 913 → 9 − 1 + 3 = 11 → Divisible by 11 | |
| 13 | Add 4 times the last digit to the remaining number. The result divides by 13. | 299 → 29 + (9×4) = 65 (65 ÷ 13 = 5) → Divisible by 13 |
The Multiple-of-6 Shortcut (6k ± 1)
Every prime number greater than 3 is always next to a multiple of 6 (either one less or one more).
Why this always works: Every whole number falls into one of six patterns around multiples of 6: 6k, 6k+1, 6k+2, 6k+3, 6k+4, or 6k+5 (which is 6k−1).
- 6k, 6k+2, and 6k+4 are always even numbers, so they can be divided by 2.
- 6k+3 can always be divided by 3.
Helpful Note: This rule helps narrow things down, but not every number of this form is prime. For example, 25 (24+1) and 35 (36−1) fit the pattern, but both can be divided by 5. Always check with division.
Why There Is No Simple Formula for Primes
In 1772, mathematician Leonhard Euler discovered a famous formula, n² + n + 41, that produces 40 prime numbers in a row (41, 43, 47, 53, 61, ..., up to 1,601).
However, at n = 40, the formula gives 40² + 40 + 41 = 1,681 = 41 × 41. Mathematicians have proven that no single algebraic formula can produce only prime numbers forever.
1 to 100 Prime Number Chart
Interactive 10×10 visual grid. Watch how composite numbers are eliminated step by step.
Prime Numbers from 1 to 1,000
There are exactly 168 prime numbers between 1 and 1,000.
Interactive Diagram: Primes Across Groups of 100
Click any bar below to view the primes in that group of 100.
View All 168 Prime Numbers Up to 1,000
Click any prime below to check it in the calculator.
Key Prime Milestones
Notable prime numbers that mark important landmarks as numbers grow.
Key Prime Milestones
These benchmark primes mark important landmarks as numbers grow larger:
#1 → 2
p₁ = 2The smallest prime number, and the only even prime number in existence. All other prime numbers are odd.
#25 → 97
p₂₅ = 97The largest two-digit prime number. Exactly 25 prime numbers live between 1 and 100.
#100 → 541
p₁₀₀ = 541The 100th prime number. About 18.5% of all numbers up to 541 are prime numbers.
#1,000 → 7,919
p₁₀₀₀ = 7,919The 1,000th prime number. Shows that primes become rarer as numbers get bigger: it takes numbers up to 7,919 to reach 1,000 primes (12.6% are prime).
#5,000 → 48,611
p₅₀₀₀ = 48,611The 5,000th prime number. Sits just beneath 50,000, where roughly 10.3% of numbers are prime.
#10,000 → 104,729
p₁₀₀₀₀ = 104,729The 10,000th prime milestone. Our lookup tool finds any prime up to this mark instantly.
How Many Primes Exist? (Prime Counting)
See how many primes exist up to any number, and discover why primes appear less often as numbers get bigger.
Prime Counts and Percentages by Powers of 10
As numbers get bigger, prime numbers appear less often, though they go on forever. Notice how the estimated formula gets closer to the real count as numbers grow:
| Up to Number (x) | Exact Primes Found | Prime Percentage (%) | Estimated Count | Difference (%) |
|---|---|---|---|---|
| 10 | 4 | 40.00% | 4.34 | +8.5% |
| 100 | 25 | 25.00% | 21.71 | −13.1% |
| 1,000 | 168 | 16.80% | 144.76 | −13.8% |
| 10,000 | 1,229 | 12.29% | 1,085.74 | −11.7% |
| 100,000 | 9,592 | 9.59% | 8,685.89 | −9.4% |
| 1,000,000 | 78,498 | 7.85% | 72,382.41 | −7.8% |
| 10,000,000 | 664,579 | 6.65% | 620,420.69 | −6.6% |
| 100,000,000 | 5,761,455 | 5.76% | 5,428,681.02 | −5.8% |
What Does π(x) Mean?
In prime math, π(x) does not mean the circle number 3.14159. Instead, mathematicians use the Greek letter π (pi) as a shorthand for 'count of primes up to x'. For example, π(10) = 4, because there are 4 primes up to 10: 2, 3, 5, and 7.
Every time you pass a prime number, this count simply goes up by 1.
The Prime Number Theorem
Proven in 1896, this famous math theorem shows that as numbers grow, the count of prime numbers follows an easy formula based on logarithms:
This theorem reveals that the chance of a random number near x being prime is roughly 1 divided by the natural logarithm of x (written as 1 / ln(x)).
Find Prime Numbers in a Range
Find, count, and calculate the exact total sum of primes between any two numbers.
Find the Next and Previous Prime
Find the closest prime numbers just above and below your number, and see how far away they are.
Strict Neighbors vs. Including Your Number
When searching for nearby primes, you can look for primes strictly above or below your number, or include your number if it is already prime:
- Previous Prime: The largest prime smaller than your number. For 97, the previous prime is 89.
- Next Prime: The smallest prime bigger than your number. For 97, the next prime is 101.
- Largest Prime Up to n: If your number is already prime (like 97), the answer is 97. If it is composite (like 90), the answer is 89.
Bertrand's Rule & Equal Distance Ties
How far away can the next prime be? A famous math rule proven in 1850 shows that for any number greater than 3, there is always at least one prime between that number and double its value (between n and 2n).
Equal Distances: Sometimes the previous and next primes are the exact same distance away! For example, for 6, the previous prime is 5 (1 step away) and the next is 7 (1 step away). Both are equally close!
Prime Factorisation with Steps
See how any composite number breaks down into prime factors.
Interactive Factor Tree & Division Ladder
Enter any whole number to see both a visual factor tree and step-by-step division steps.
Coprime Number Checker
Check whether two numbers share any common factors other than 1 using easy step-by-step division.
Ancient mathematician Euclid discovered that finding the greatest common factor is just like finding the largest square tile that can completely cover a rectangle without any gaps or overlapping:
Step-by-Step Division Steps
Can Two Composite Numbers Be Coprime?
Yes, absolutely! Two numbers are coprime (also called relatively prime) if their greatest common factor is 1, even if neither number is prime on its own.
For example, look at 8 and 9. Neither number is prime! (8 = 2 × 2 × 2 and 9 = 3 × 3). But because they do not share any factors with each other, their greatest common factor is 1, which makes them coprime.
Where Coprime Numbers Are Used
- Counting Shared Factors: Mathematicians count how many numbers up to a number share no common factors with it.
- Computer Security: Internet encryption systems pick coprime numbers to create secure digital locks and keys.
- Data Storage: Computer programs use coprime numbers to spread saved data evenly and avoid slowdowns.
Numbers That Look Prime but Aren't
Tricky composite numbers that frequently fool students, programmers, and puzzle solvers.
Why 91 Fools Almost Everyone
Why These Numbers Fool Us
91 ends in 1, so it isn't even. Its digits add up to 10, so it can't be divided by 3. And it doesn't end in 5. Because 7 × 13 isn't something most people memorize in school multiplication tables, our brains naturally assume 91 must be prime!
Special Types of Prime Numbers
Explore unique families of prime numbers with fascinating patterns.
Quick Special-Prime Scanner
Test any prime to see every special mathematical family it belongs to simultaneously.
Special Prime Families
Explore unique families of prime numbers with fascinating patterns.
Twin Primes
Pairs of prime numbers that are separated by just 2 numbers: (p, p + 2). Mathematicians believe there are infinitely many of these pairs, but nobody has been able to prove it yet!
Mersenne Primes
Primes that can be written as 2 raised to a power minus 1 (2ᵖ − 1). These include the largest known prime numbers in the world.
Sophie Germain Primes
A prime number p where doubling it and adding 1 (2p + 1) also gives a prime number. These are useful in computer security.
Palindrome Primes
A prime number that reads the exact same forwards and backwards (like 131 or 727). Except for 11, all palindrome primes have an odd number of digits!
How Our Calculator Works
Clear, verified math methods with 100% honest results.
Interactive Flowchart: Step-by-Step Math Engine
Follow the exact steps our tool uses to check any whole number.
Everyday Numbers: Step-by-Step Division
For normal numbers, the calculator tests factors up to the square root using smart shortcuts. If no number divides in evenly, the number is 100% proven prime.
Range Lists: Prime Grid Sieve
To find all primes in a range, our tool uses the ancient Sieve method, quickly crossing off multiples of each prime to reveal the primes left behind.
Giant Numbers: Advanced Prime Checks
For huge numbers up to 18 quintillion, our tool runs proven mathematical tests (the Miller-Rabin test across 7 certified bases) to guarantee 100% certainty with zero guesswork.
Exact BigInt Math
Normal web calculators make rounding mistakes when numbers get too big. Our calculator uses special exact-math technology (BigInt) so every single digit is 100% accurate.
| Tool / Action | Math Method Used | Tested Range | Result Accuracy |
|---|---|---|---|
| Check Prime | Square root check & advanced prime test | Numbers up to 18 quintillion | 100% Proven (0% Error) |
| Prime Factors | Step-by-step division test | Numbers up to 1 trillion | 100% Proven (0% Error) |
| Nth Prime | Fast prime sequence lookup | Up to the 10,000th prime (104,729) | 100% Proven (0% Error) |
| Primes in Range | Prime grid sieve | Ranges up to 10,000 numbers | 100% Proven (0% Error) |
Why Prime Numbers Matter
Beyond math class, prime numbers protect internet security and power modern technology.
Interactive Visual: How Primes Lock Secret Messages (RSA Demo)
See how multiplying two prime numbers creates a one-way digital lock that protects information online.
Interactive RSA Key Scale Explorer
Compare toy classroom locks with modern banking encryption scales:
Educational demonstration above uses small numbers (like 35) so every exponent step is visible by hand.
Prime numbers are often called the 'building blocks of math' because every whole number can be made by multiplying prime numbers together. Because multiplying primes is easy, but untangling them is very hard, primes are the secret backbone of digital security.
Internet Security & Passwords
When you log into a website or send a secure payment, prime numbers protect your data. It's easy for computers to multiply two large primes, but nearly impossible for hackers to break them back apart.
Fast Computer Search
Databases and search engines use prime numbers to distribute stored information evenly across computer memory, avoiding clumping and keeping searches fast.
Math Mysteries
Prime numbers hold some of the most famous unsolved mysteries in science, challenging researchers to understand the patterns hidden within numbers.
Accuracy, Verification & Limits
Tested math methods, exact calculations, and complete transparency.
Live Browser Engine Self-Test
Verify engine.js directly in your browser against adversarial pseudoprimes, boundaries, and numbers above IEEE-754 float precision.
100% Proven Prime Guarantee
For all numbers up to 18 quintillion, our calculator uses certified mathematical tests proven by mathematicians. Our tests are real mathematical proofs with 0% chance of error.
No Rounding Mistakes
Many online calculators make rounding errors on large numbers. We use exact-digit math (BigInt) so that every single digit is preserved without rounding.
Thoroughly Tested
Every update to our calculator is checked against thousands of known prime numbers, tricky numbers that fool basic tests, and verified math tables to ensure 100% accuracy.
Math Sources & References
- Crandall, R., & Pomerance, C. (2005): Prime Numbers: A Computational Perspective. 2nd ed., Springer-Verlag. (Standard reference on prime testing algorithms).
- Sorenson, J., & Webster, J. (2015): Strong Pseudoprimes to Twelve Prime Bases. Mathematics of Computation, 85(301), pp. 2489–2503.
- OEIS: The On-Line Encyclopedia of Integer Sequences (OEIS): Sequence A000040: The Prime Numbers.
- GIMPS: Great Internet Mersenne Prime Search (GIMPS): Official tracker for world-record largest known primes. (2¹³⁶²⁷⁹⁸⁴¹ − 1).
- CP-Algorithms: CP-Algorithms: Certified Miller-Rabin Primality Testing.
Frequently Asked Questions
Simple, clear answers to common questions about prime numbers.
What is a prime number?
A prime number is a whole number greater than 1 that can only be divided evenly by 1 and itself. Common examples include 2, 3, 5, 7, 11, 13, and 97.
Why are 0 and 1 not considered prime numbers?
To be a prime number, a number must have exactly two factors: 1 and itself. The number 1 only has one factor (1), so it cannot be prime. The number 0 can be divided by any number without a remainder, so it has endless factors.
Why is 2 the only even prime number?
Every even number greater than 2 can be divided by 2, meaning it has at least three factors (1, 2, and itself). For example, 4 = 2 × 2 and 6 = 2 × 3. Because 2 only has two factors (1 and 2), it is the only even number that is prime.
Are 7 and 9 both prime numbers?
No. 7 is prime because only 1 and 7 divide into it evenly. But 9 is not prime because 3 × 3 = 9. It has three factors: 1, 3, and 9.
How do you check if a large number is prime?
For smaller numbers, you only need to test prime factors up to the number's square root. For very large numbers, computers use fast, proven mathematical checks to verify whether a number has any factors, giving a 100% exact result.
What is the largest prime number?
There is no single largest prime number because prime numbers go on forever. However, the largest prime number discovered so far by researchers is 2^136,279,841 − 1, which has over 41 million digits.
What are coprime (relatively prime) numbers?
Two numbers are coprime if they do not share any factors other than 1. Neither number has to be prime on its own. For example, 8 and 9 are both composite numbers, but because their only shared factor is 1, they are coprime.
How many prime numbers exist between 1 and 100?
There are exactly 25 prime numbers between 1 and 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, and 97. Added together, their sum is 1,060.
How does prime factorization work on a Casio fx-991ES calculator?
On models like the Casio fx-991ES PLUS or fx-115ES PLUS, type your number, press [=], then press [SHIFT] followed by the [FACT] key. The screen will show the prime factors.