Prime Number Calculator

Primes are the building blocks of whole numbers, since every integer above 1 is a product of primes. 97 is prime, with 89 the previous prime and 101 the next. Use the tool to check homework, to find factors and to see gaps between primes, which grow irregularly.

Knowing a number's smallest prime factor also starts its prime factorization.

Prime Number Calculator: inputs

Calculated result
Smallest prime factor97
Next prime above101
Previous prime below89

Prime Number Calculator: Whole number sensitivity

Prime Number Calculator: Whole number and Smallest prime factor5 calculations vary the “Whole number” input while holding the other entered inputs constant.78287397971071071162

Prime Number: worked example

Whole number97
Smallest prime factor97
Next prime above101
Previous prime below89

Prime Number: formula

Trial division by every integer up to √n finds the smallest factor; the next and previous primes are found the same way

Prime Number: Wolfram MathWorld

The supported input is an integer greater than 1. Trial division stops at the square-root bound because a composite number has at least one factor no larger than that bound. For 91, the factor 7 gives 7 × 13.

For a prime input, the smallest-factor output is the input itself. Finding neighboring primes repeats primality tests on nearby integers, and trial division is not a practical method for cryptographic-size numbers.

Prime Number: changing Whole number

Whole numberSmallest prime factorNext prime abovePrevious prime below
7827973
8738983
97 (example)9710189
107107109103
1162127113

Prime Number: compare input ranges

InputTested fromToSmallest prime factor: low inputSmallest prime factor: high inputSwing
Whole number871073107104 (107%)

Prime Number: individual input comparisons

InputValueSmallest prime factorNext prime abovePrevious prime below
Whole number7827973
8738983
979710189
107107109103
1162127113

Prime Number: which assumptions move the result?

Prime Number: Smallest prime factor as Whole number changesSmallest prime factor starts at 2. Moving Whole number from 78 to 116 changes it to 2, with the displayed formula kept fixed.78287397971071071162
Chart quantityDisplayed settings
Whole number78 → 116
Smallest prime factor2 → 2

Prime Number: values and definitions

Quantity and definitionValue used
Whole number — Any whole number up to 1,000,000,000.97
Smallest prime factor97
Next prime above101
Previous prime below89

Prime Number: half and double Whole number

Whole numberSmallest prime factor
48.57
9797
1942

Common error: Calling 1 a prime. It has only one factor, and by convention primes must have exactly two, so 2 is the first prime.

Trial division is fast for small numbers but impractical for numbers with hundreds of digits, where probabilistic tests are used. The number 1 is not prime by convention, and 2 is the only even prime. There is no simple formula for the nth prime, and gaps between primes do not follow a pattern that can be predicted exactly.

Number Theory & Precision calculators: GCF & LCM Calculator, Prime Factorization Calculator, Scientific Notation Calculator, Percent Error Calculator, Number Base Converter Calculator, Factorial Calculator.

A prime has no factors other than 1 and itself, so the smallest prime factor of a prime is the number itself. For 97 the search up to its square root finds nothing, which proves it prime. The neighbors are 89 below and 101 above.

Primes thin out as numbers grow but never run out, and the gaps between them are irregular, which is why they show up in encryption.

Look at the smallest factor. If it equals the number, the number is prime. Otherwise it names the first divisor that breaks it apart.

Break a number into primes on the prime factorization calculator, find common factors on the GCF and LCM page, and check divisibility on the modulo calculator. The Fibonacci and factorial calculators explore other sequences. Cryptography relies on the difficulty of factoring large numbers.

Is 1 a prime number?

No. By convention 1 is neither prime nor composite, which keeps the unique factorization of numbers into primes true.

Why are primes important?

Every integer greater than 1 has a unique prime-power factorization apart from order. For example, 84 = 2² × 3 × 7. Neither 0 nor 1 belongs to that statement.

Factoring large integers underpins some cryptographic systems; this small-number trial-division tool is not a cryptographic key generator.

What is a prime number?

A whole number greater than 1 whose only divisors are 1 and itself, such as 2, 3, 5, 7 and 11.