Quick answer
A number n is prime if n > 1 and no integer from 2 up to √n divides it. 97 is prime (no divisor up to 9), and the next prime after it is 101. The calculator accepts numbers up to 10¹².
Enter a whole number. The calculator says whether it is prime or composite and gives the next prime.
Related tools: Complex Number Calculator: Add, subtract, multiply and divide complex numbers. Random Number Generator: Random integers in a range, optionally repeatable with a seed. Scientific Calculator: Evaluate expressions with functions, constants, powers and factorials.
How to use the Prime Number Calculator
- Enter number (a whole number, between 0 and 1000000000000).
- Press Calculate to see the result, and use Reset to start again.
| Input | What to enter | Allowed values |
|---|---|---|
| Number | A whole number | ≥ 0, ≤ 1000000000000 |
Formula and method
Formula
n is prime if n > 1 and no integer 2 ≤ d ≤ √n divides n
IEEE-754 double precision; shown to at most 6 decimal places.
Trial division by 2 and odd numbers up to √n.
Worked examples
These examples are verified: each one is an automated test case that the live calculator must reproduce exactly.
Example 1
Inputs: Number = 97.
| Result | Value |
|---|---|
| Result | Prime |
| Next prime | 101 |
Example 2
Inputs: Number = 91.
| Result | Value |
|---|---|
| Result | Not prime |
| Smallest factor | 7 |
| Next prime | 97 |
The first line is the headline result (result). Below it the prime Number Calculator lists next prime, which describe the same case from other angles. IEEE-754 double precision; shown to at most 6 decimal places.
Why only check up to the square root
If n has a divisor larger than √n, it must also have a matching one smaller than √n, so testing 2, 3, 5, 7 and so on up to √n is enough. For 97, √97 ≈ 9.8, so checking 2, 3, 5 and 7 settles it.
Edge cases
0 and 1 are not prime; 2 is the only even prime. A composite result can be factored by dividing out the smallest divisor repeatedly. For primality of very large numbers, such as those used in cryptography, probabilistic tests are used instead; this tool is limited to 10¹².
How the result changes with number
Holding every other input at the first worked example, this table changes only number. It shows how sensitive the answer is to that one value; each row was produced by running this calculator.
| Number | Result | Smallest factor | Next prime |
|---|---|---|---|
| 49 | Not prime | 7 | 53 |
| 194 | Not prime | 2 | 197 |
| 388 | Not prime | 2 | 389 |
What happens with invalid input
These messages are produced by the calculator itself, so you know what to fix.
- Number: entering "-3" shows "Number must be at least 0." beside that field and no result.
Choosing between the Prime Number Calculator and similar calculators
Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.
| Calculator | You enter | It returns |
|---|---|---|
| [Complex Number Calculator](/math/complex-number-calculator/) | real part of z₁, imaginary part of z₁ and operation | Result |
| [Random Number Generator](/math/random-number-generator/) | minimum, maximum and how many | Random numbers |
| [Scientific Calculator](/math/scientific-calculator/) | expression and angle mode | Result |
| [Roman Numeral Converter](/math/roman-numeral-converter/) | convert and value | Roman numeral |
| [Fibonacci Sequence Calculator](/math/fibonacci-sequence-calculator/) | position n | F(10) |
Assumptions and limitations
- 0 and 1 are not prime
- Maximum 10^12
If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for number to confirm this.
Frequently asked questions
Is 1 a prime?
No: primes have exactly two divisors.
What is the next prime after 100?
101 is the next prime after 100.
How many primes are below 100?
There are 25 primes below 100, from 2 up to 97.
What does the Prime Number Calculator calculate?
Check whether a number is prime and find the next prime. It returns Result and Next prime.
What formula does the Prime Number Calculator use?
n is prime if n > 1 and no integer 2 ≤ d ≤ √n divides n. Trial division by 2 and odd numbers up to √n.
How is the result rounded or limited?
IEEE-754 double precision; shown to at most 6 decimal places. 0 and 1 are not prime.
What are the limits of this calculator?
0 and 1 are not prime. Maximum 10^12.
What is an example of a prime Number result?
With number 97, the result is Prime.
Related calculators
- Complex Number Calculator — Add, subtract, multiply and divide complex numbers.
- Random Number Generator — Random integers in a range, optionally repeatable with a seed.
- Scientific Calculator — Evaluate expressions with functions, constants, powers and factorials.
- Roman Numeral Converter — Convert between numbers and Roman numerals (1–3999).
- Fibonacci Sequence Calculator — The nth Fibonacci number and the sequence leading to it.
- Factorial Calculator — n! computed exactly.
Sources
- OpenStax, Algebra and Trigonometry 2e (Rice University): exponents, radicals, logarithms and inverse trigonometric functions
Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.