Skip to content
CalculatorAtlas

Prime Number Calculator

Tested

Check if a number is prime and find next primes.

Tested, not yet published. The formula for this calculator is implemented and passes its automated checks. This page stays non-indexable until it is reviewed and published.

Results

Enter your values and press Calculate. Results appear here.

  • • Result

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

  1. Enter number (a whole number, between 0 and 1000000000000).
  2. Press Calculate to see the result, and use Reset to start again.
Inputs of the Prime Number Calculator
InputWhat to enterAllowed values
NumberA 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.

Results of example 1
ResultValue
ResultPrime
Next prime101

Example 2

Inputs: Number = 91.

Results of example 2
ResultValue
ResultNot prime
Smallest factor7
Next prime97

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.

How the result changes with number
NumberResultSmallest factorNext prime
49Not prime753
194Not prime2197
388Not prime2389

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.

Choosing between the Prime Number Calculator and similar calculators
CalculatorYou enterIt returns
[Complex Number Calculator](/math/complex-number-calculator/)real part of z₁, imaginary part of z₁ and operationResult
[Random Number Generator](/math/random-number-generator/)minimum, maximum and how manyRandom numbers
[Scientific Calculator](/math/scientific-calculator/)expression and angle modeResult
[Roman Numeral Converter](/math/roman-numeral-converter/)convert and valueRoman numeral
[Fibonacci Sequence Calculator](/math/fibonacci-sequence-calculator/)position nF(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.

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.