Prime Number: worked example
| Whole number | 97 |
|---|---|
| Smallest prime factor | 97 |
| Next prime above | 101 |
| Previous prime below | 89 |
Prime Number: formula
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 number | Smallest prime factor | Next prime above | Previous prime below |
|---|---|---|---|
| 78 | 2 | 79 | 73 |
| 87 | 3 | 89 | 83 |
| 97 (example) | 97 | 101 | 89 |
| 107 | 107 | 109 | 103 |
| 116 | 2 | 127 | 113 |
Prime Number: compare input ranges
| Input | Tested from | To | Smallest prime factor: low input | Smallest prime factor: high input | Swing |
|---|---|---|---|---|---|
| Whole number | 87 | 107 | 3 | 107 | 104 (107%) |
Prime Number: individual input comparisons
| Input | Value | Smallest prime factor | Next prime above | Previous prime below |
|---|---|---|---|---|
| Whole number | 78 | 2 | 79 | 73 |
| 87 | 3 | 89 | 83 | |
| 97 | 97 | 101 | 89 | |
| 107 | 107 | 109 | 103 | |
| 116 | 2 | 127 | 113 |
Prime Number: which assumptions move the result?
Prime Number: values and definitions
| Quantity and definition | Value used |
|---|---|
| Whole number — Any whole number up to 1,000,000,000. | 97 |
| Smallest prime factor | 97 |
| Next prime above | 101 |
| Previous prime below | 89 |
Prime Number: half and double Whole number
| Whole number | Smallest prime factor |
|---|---|
| 48.5 | 7 |
| 97 | 97 |
| 194 | 2 |
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.