Prime Number Calculator
Check whether a whole number is prime or composite, list its factors and prime factorization, and find the nearest primes.
Any whole number from 0 to 1,000,000,000,000. Results update as you type.
97 has exactly two positive factors: 1 and 97.
Factors
1, 97
Why is 97 prime?
To test whether 97 is prime, we only need to check divisors up to √97 ≈ 9.85. We checked the primes 2, 3, 5, 7, and none divide 97 evenly. Since no prime up to √97 divides 97 evenly, 97 is prime.
How was this calculated?
Step 1 — Find the square root
√97 ≈ 9.85
If 97 had a factor larger than √97, it would be paired with one smaller than √97, so only divisors up to 9.85 need checking.
Step 2 — Test prime divisors in order
- 97 ÷ 2 → not a whole number
- 97 ÷ 3 → not a whole number
- 97 ÷ 5 → not a whole number
- 97 ÷ 7 → not a whole number
Step 3 — Conclusion
No prime up to √97 divides 97 evenly, so 97 is prime.
This prime number calculator checks whether a whole number is prime, composite, or neither. It lists every positive factor, gives the prime factorization of composite numbers, and shows the previous and next prime numbers.
Enter a number to get the answer instantly. The "How was this calculated?" steps below the result show each divisor tested up to the square root.
Worked Calculation Examples
| Scenario | Result | Calculation Step |
|---|---|---|
| Is 97 prime? | Prime | √97 ≈ 9.85, so only the primes 2, 3, 5, and 7 need testing. None divide 97 evenly, so its only factors are 1 and 97. |
| Is 91 prime? | 91 = 7 × 13 | √91 ≈ 9.54. 2, 3, and 5 do not divide 91, but 91 ÷ 7 = 13, so 91 is composite with factors 1, 7, 13, and 91. |
| Is 1 prime? | Neither | 1 has only one positive factor (1 itself). A prime needs exactly two, and a composite needs more than two, so 1 is neither. |
| Is 100 prime? | 100 = 2² × 5² | 100 is even, so 2 divides it and it is composite. Dividing out primes: 100 ÷ 2 = 50, 50 ÷ 2 = 25, 25 ÷ 5 = 5, 5 ÷ 5 = 1. The nearest primes are 97 and 101. |
Prime vs. Composite Numbers
A prime number is a whole number greater than 1 whose only positive factors are 1 and itself, such as 2, 3, 5, 7, 11, and 97. A composite number is a whole number greater than 1 with at least one other factor. For example, 91 is composite because 7 × 13 = 91.
0 and 1 are neither prime nor composite. 1 has only one positive factor, and 0 is divisible by every positive integer, so neither fits the definition. 2 is the only even prime, because every larger even number is also divisible by 2. Euclid proved around 300 BCE that there are infinitely many primes, so the list never ends.
Factors and Prime Factorization
The factors of a number are the whole numbers that divide it with no remainder. The factors of 12 are 1, 2, 3, 4, 6, and 12. Prime factorization writes a composite number as a product of primes, using exponents for repeated primes: 12 = 2² × 3 and 360 = 2³ × 3² × 5.
By the fundamental theorem of arithmetic, every whole number greater than 1 has exactly one prime factorization, apart from the order of the factors. That makes it the standard starting point for finding the greatest common factor or least common multiple of several numbers, and for simplifying fractions.
Why Checking Divisors Up to the Square Root Is Enough
Factors come in pairs that multiply to the number. For 100, those pairs are 1 × 100, 2 × 50, 4 × 25, 5 × 20, and 10 × 10. In every pair, one factor is at most √100 = 10. So if no number up to √n divides n, no larger number can either.
Only prime divisors need testing, because any composite divisor is a product of smaller primes that would already have been found. To check 97, the calculator tests just 2, 3, 5, and 7, the primes below √97 ≈ 9.85. The calculator's step-by-step working shows this test for any number you enter.
How to Use the Prime Number Calculator
- Enter a whole number from 0 to 1,000,000,000,000. The result updates as you type.
- Read the result card to see whether the number is prime, composite, or neither (0 and 1).
- Review its factors, and for composite numbers, its prime factorization.
- Check the previous and next prime numbers shown below the result.
- Follow "How was this calculated?" below the result to see each divisor tested up to the square root.
Frequently Asked Questions
What is a prime number?
A prime number is a whole number greater than 1 whose only positive factors are 1 and itself. The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29.
How do you check if a number is prime?
Divide it by each prime number up to its square root. If none divide it evenly, the number is prime. If one does, it is composite. For example, to check 29 you only test 2, 3, and 5, because √29 ≈ 5.39.
Is 1 a prime number?
No. A prime must have exactly two positive factors, and 1 has only one (itself). 1 is neither prime nor composite.
Is 0 a prime number?
No. Prime and composite numbers must be positive integers greater than 1. 0 is divisible by every positive integer, so it is neither prime nor composite.
Why is 2 the only even prime number?
Every even number greater than 2 is divisible by 2, so it has at least three factors: 1, 2, and itself. 2 has only the factors 1 and 2, so it is prime.
What is the difference between prime and composite numbers?
A prime has exactly two positive factors: 1 and itself. A composite number has more than two. For example, 13 is prime (factors 1 and 13), while 15 is composite (factors 1, 3, 5, and 15).
Why do you only check divisors up to the square root?
Factors pair up to multiply to the number, and in each pair one factor is no larger than the square root. If nothing up to √n divides n, there is no larger divisor either.
What is prime factorization?
Prime factorization writes a number as a product of prime numbers, such as 60 = 2² × 3 × 5. Every whole number greater than 1 has exactly one prime factorization, apart from the order of the factors.
Can negative numbers be prime?
Under the standard definition, no. Prime numbers are positive integers greater than 1, so negative integers such as -7 are not classified as prime.
How does this prime number calculator work?
It uses trial division. It finds the smallest prime that divides your number, testing up to the square root, then keeps dividing to build the full prime factorization. The factor list and nearest primes are calculated from the same results.
Related Calculators
GCF Calculator
Find the greatest common factor of two or more whole numbers, with verification, Euclidean algorithm steps, common factors, and prime factorization.
LCM Calculator
Find the least common multiple of two or more whole numbers, with verification, GCD steps, and the prime factorization method.
Scientific Calculator
Advanced math calculator supporting trigonometry, logs, exponentials, and roots.
Percentage Calculator
Calculate percentages, percent of a number, and percentage changes fast.
Percentage Increase Calculator
Calculate the percentage increase or decrease from an old value to a new value, the new value after an increase, or the original value, with steps.
Fraction Calculator
Add, subtract, multiply, and divide fractions.
Last updated: September 27, 2026.