This prime number calculator tests primality, finds the neighboring primes around any number, and counts how many primes live below a limit (the π(x) function).

Is Prime?–
Next Prime–
Previous Prime–
π(x) — Primes ≤ x–

Trial division to √n settles primality quickly for everyday sizes (and reports the smallest factor when composite). The sieve behind π(x) is the 2,300-year-old Eratosthenes design — primes thin out as numbers grow (the Prime Number Theorem: π(x) ≈ x/ln x), yet never run out, per Euclid’s two-line proof.

Primality, Neighbors, and the Prime Census

Composites decompose on our Prime Factorization Calculator; this page adjudicates prime-or-not and maps the local prime geography. Part of our Math Calculators collection.

Worked Values (Verified)

  • 97 (default): prime — the 25th prime; next is 101, previous 89; and π(100) = 25, closing the loop neatly
  • 1 is not prime (by definition — it would break unique factorization), and 2 is the only even prime
  • π(1,000) = 168; π(1,000,000) = 78,498 — against x/ln x estimates (144.8 / 72,382), the theorem’s approximation improving with scale
  • Twin-prime spotting with the neighbors: 97’s bracket (89, 101) contains no twin; try 59/61 and 41/43 — pairs differing by 2, conjectured infinite, proven bounded-gap (Zhang, 2013)

Why Primes Run the Modern World

  • RSA cryptography: multiplying two large primes is trivial, factoring the product is (classically) infeasible — this page’s small-number ease inverts at 300 digits.
  • Hash tables and pseudorandom generators use prime moduli to spread collisions evenly.
  • Sieve methods scale: segmented sieves count primes into the billions; π(x) records are a small sport of their own.
  • The distribution’s irregular regularity (gaps, twins, Goldbach) still holds unproven conjectures after centuries — primes remain mathematics’ open frontier in elementary clothing.

Related Tools

Frequently Asked Questions

How do you check if a number is prime?

Test divisibility by all primes up to √n — if none divide it, it’s prime (any factor pair must straddle √n, so finding none below it settles the question). 97: √97 ≈ 9.8; not divisible by 2, 3, 5, 7 → prime. This tool does exactly that and names the smallest factor when the number is composite.

Is 1 a prime number?

No — by deliberate definition. Primes are integers > 1 with exactly two divisors (1 and itself); 1 has only one. Making it prime would break the Fundamental Theorem of Arithmetic (unique factorization would allow padding with endless 1s).

How many primes are there below 100?

25: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97. The counter here (π(x), the prime-counting function) extends the census to ten million instantly via the sieve of Eratosthenes.

What is the largest known prime?

As of the mid-2020s, a Mersenne prime 2¹³⁶²⁷⁹⁸⁴¹ − 1 with over 41 million digits (found 2024 by the GIMPS distributed project). It changes by discovery, not by formula — Euclid proved infinitely many primes exist, so the record is a frontier marker, never a maximum.

Why are primes used in encryption?

Because factoring is asymmetric labor: multiplying two 150-digit primes takes microseconds; recovering them from the 300-digit product would take classical computers geological time. RSA builds public keys from the product and private keys from the hidden factors — the gap this page’s tiny examples can’t convey but faithfully illustrate at small scale.

Is this prime number calculator free?

Yes — free, instant, no sign-up.