Prime Number Checker
Check whether a number is prime, find its smallest factor and prime factorization, and see the next and previous prime. A prime is a whole number greater than 1 whose only divisors are 1 and itself. Example: with number to test 97, the result is Is it prime? = Yes, prime.
Last updated · By S. Dilshan · Runs in your browser, nothing is uploaded
Step-by-Step Solution
How do you use the Prime Number Checker?
Enter a whole number up to ten trillion. The checker tests it for primality by trial division, shows the smallest prime factor and the full prime factorization of composite numbers, and finds the nearest primes above and below.
What formula does the Prime Number Checker use?
A prime is a whole number greater than 1 whose only divisors are 1 and itself. It is enough to test divisors up to √n, because any factor larger than √n pairs with one smaller. After checking 2 and 3, only numbers of the form 6k ± 1 can be prime, which cuts the work to a third.
Worked example: Number to test 97
To test 97, √97 ≈ 9.85, so check 2, 3, 5 and 7. None divides 97, so it is prime, and the next prime is 101. By contrast 91 looks prime but equals 7 × 13.
With the default values the calculator returns Is it prime? = Yes, prime; Smallest prime factor = 97; Prime factorization = 97 is prime; Next prime = 101.
Where Is This Calculation Used?
Primes underpin modern cryptography, hashing and random-number generation, and they are the building blocks of every integer. The checker is also a quick way to verify homework such as “is 221 prime?” (no, 13 × 17).
The numbers 0 and 1 are not prime, and 2 is the only even prime. Twin primes such as 41 and 43 differ by exactly 2, and the gaps between primes grow slowly as numbers get larger.
What are the most common mistakes with the Prime Number Checker?
- Calling 1 a prime; it has only one divisor.
- Assuming every odd number is prime, for example 9, 15, 21 and 91.
- Testing divisors beyond √n, which wastes time but is harmless; stopping before √n is the real error.
What Is the Tested Example for the Default Values?
This example is computed by the same code that powers the calculator above, so you can compare it with your own numbers or a textbook answer.
| Input: Number to test | 97 |
|---|---|
| Is it prime? | Yes, prime |
| Smallest prime factor | 97 |
| Prime factorization | 97 is prime |
| Next prime | 101 |
| Previous prime | 89 |
Where Can You Verify These Formulas?
The definitions and formulas on this page follow standard references. Check them against these sources:
Built and maintained by S. Dilshan. Found a mistake? Email [email protected] with the page address.
Frequently Asked Questions
How do you check if a number is prime?
Divide it by every prime up to its square root. If none divides it evenly, the number is prime.
Why is 1 not considered a prime number?
No. A prime needs exactly two distinct divisors, and 1 has only one, so it is neither prime nor composite.
What is the smallest prime number?
2, which is also the only even prime.