Prime Number Calculator

NUMBER THEORY

Check whether a number is prime, and see the nearest primes. Enter a whole number.

Result
—
Prime or composite.

Usage Tip

To test a small number, you only need to check division by primes up to its square root.

THE MATH
Prime: a whole number above 1 with exactly two divisors (1 and itself)
Tested by trial division up to the square root
Prime numbers are the building blocks of the integers; every whole number factors uniquely into primes.
Composite numbers have at least one divisor besides 1 and themselves.
2 is the only even prime; all other evens are composite.
1 is neither prime nor composite by definition.
The next and previous primes are shown for context.
Practical Notes

A prime number is a whole number greater than 1 whose only factors are 1 and itself. The first primes are 2, 3, 5, 7, 11, and 13, and 2 is the only even prime. To test a number, you only need to check for divisors up to its square root, since any larger factor pairs with a smaller one.

The calculator also shows the nearest primes on either side, which is useful for choosing gear tooth counts, hash table sizes, or spacing patterns that avoid common factors. The number 1 is not prime, and there are infinitely many primes. Primes thin out as numbers grow, but they never run out, and very large primes are central to modern encryption.

Spotted an error or have a suggestion for this calculator? Let us know →
Scroll to Top

The calculators and tools on Formula Factory are provided for general guidance and informational purposes only. Results are estimates based on standard formulas and the values you enter — they do not constitute professional engineering, electrical, or architectural advice. Always verify calculations with a qualified professional before making decisions for any safety-critical, code-compliance, or commercial application. Formula Factory makes no representations or warranties as to the accuracy or completeness of any result, and accepts no liability for errors, omissions, or any outcomes arising from reliance on this information.