Prime Number Checker
Is n prime? Trial division up to √n; identifies smallest divisor and nearest primes if composite.
Result
Loading calculator…
—
How to use this calculator
- Enter integer.
- Read result + nearest primes.
About this calculator
A prime is a positive integer >1 with exactly two divisors: 1 and itself. The 6k±1 trial-division algorithm tests divisors up to √n: every prime >3 is of form 6k±1, so we skip 2/3 of integers. For n up to 10^15, this finishes in milliseconds. Beyond that, probabilistic tests (Miller-Rabin) are used. Famous primes: 2 (only even), 7 (Mersenne), 25-million-digit primes for crypto.
Frequently asked
Is 1 prime?+
No — by convention, primes are integers ≥2 with exactly two divisors. 1 has only itself.
Is 0 prime?+
No — 0 has every positive integer as a divisor.
Why test up to √n?+
If n has a factor f > √n, then n/f is a factor < √n. So checking up to √n catches all composites.
Why 6k±1 optimization?+
Every integer is 6k, 6k±1, 6k±2, or 6k+3. The 6k, 6k±2, 6k+3 forms are divisible by 2 or 3 — skip them. Only 6k±1 needs testing.
How many primes?+
Infinite (Euclid). About n/ln(n) primes ≤ n by prime number theorem.
Related calculators
Prime Factorization Calculator
n = p₁^a₁ × p₂^a₂ × … Trial division to find all prime factors with multiplicity.
GCD (Greatest Common Divisor) Calculator
Euclidean algorithm: gcd(a,b) = gcd(b, a mod b). Supports 2-6 integers.
LCM (Least Common Multiple) Calculator
lcm(a,b) = |a × b| / gcd(a,b). Smallest number that both a and b divide evenly.
Factorial Calculator (n!)
n! = 1 × 2 × … × n. Computes exactly up to 21! (number limit); approximate via Stirling for larger.
Scientific Notation Converter
Convert decimal ↔ scientific notation. Standard form a × 10^b with 1 ≤ |a| < 10.
Square Root Calculator (√n)
√n with integer-perfect-square check, simplified surd form, and decimal expansion.