Prime Number Calculator — Check, Factorize & Explore Primes

Skip to prime calculator

Loading tool…

By Muhammad Abdullah Rauf · Founder, EverydayTools.proUpdated 2026-07-05· Reviewed by EverydayTools Mathematics Team — number theory & calculator QA

What is a prime number?

A **prime number** is a whole number greater than 1 whose only positive divisors are 1 and itself. **2** is prime and the only even prime; every other even n > 2 is composite because 2 divides it. **1** is neither prime nor composite—the definition requires exactly two distinct divisors.

**Prime vs composite:** 97 has no divisor from 2 through 9 (√97 ≈ 9.8), so it is prime. 91 looks prime but 91 ÷ 7 = 13, so 91 = 7 × 13 is composite. The **fundamental theorem of arithmetic** states every integer n > 1 factors into primes in exactly one way (ignoring order).

**Prime factorization** splits a composite into prime powers—360 = 2³ × 3² × 5. Our factor tree visualizes this split step by step. **Trial division** tests divisors d from 2 to √n; if none divide evenly, n is prime. This is exact and ideal for classroom sizes.

For n up to 10¹², this calculator uses **deterministic Miller–Rabin** with fixed witness bases—probabilistic in theory but exact for the bounds we support. Lists and ranges use the **Sieve of Eratosthenes** (O(n log log n)), far faster than testing each integer alone.

**Prime density** thins as numbers grow: π(x) ≈ x/ln(x) (prime number theorem). **Twin primes** like (11, 13) differ by 2; whether infinitely many exist is still open. **Prime gaps** between consecutive primes can grow—our tool shows next/previous prime and gap size.

**Cryptography:** RSA multiplies two large secret primes. This page targets educational sizes—not 2048-bit key generation—but the RSA panel explains why primality at scale matters.

Connect to **GCF** (minimum prime exponents) and **LCM** (maximum exponents) once factors are known.

Check primality, factor composites with an interactive tree, list or range-generate primes, find the nth prime, and compare trial division vs Miller–Rabin—all locally in your browser.

How to use Prime Number Calculator — Check, Factorize & Explore Primes

  1. Choose a mode

    Check, Factorize, List, Range, Nth, or Random—quick examples load 97, 91, or primes ≤100 instantly.

  2. Enter your number or bounds

    Type n for check/factorize, an upper limit for lists, or min/max for ranges and random generation.

  3. Read the interactive result

    Verdict, factor tree, trial steps (when enabled), next/prev prime, twin check, and divisor count τ(n).

  4. Study algorithms and export

    Open the Algorithm panel for trial vs Miller–Rabin, copy or download TXT/CSV, or share a URL restoring your inputs.

  5. Continue with related math tools

    Use GCF, LCM, combination, or factorial calculators once prime structure is clear.

When to use this prime number calculator

Common real-world scenarios where this tool saves time.

Verify homework primality

Set Check mode on 91, 97, or 541. Composite answers show the smallest factor; primes show next/previous prime and gap.

Build a factor tree for GCF/LCM

Factorize 360 or 84, click tree nodes, then open the GCF or LCM calculator with prime exponents in mind.

Study prime density and sieving

List primes to 100 or range 50–150—watch the animated sieve and density chart competitors rarely include.

Find the nth prime or a random prime

Ask for the 25th prime (97) or pick a random prime between 100 and 500 for quiz questions.

Explore twin primes and gaps

Check 11, 13, or 41 to see twin-pair flags and prime-gap statistics beside the verdict.

Workflow guides

Step-by-step chains that connect related tools for common tasks.

From primality to GCF

  1. Factorize each input (e.g. 24 and 36) with the factor tree.
  2. List prime powers: 24 = 2³×3, 36 = 2²×3².
  3. Take minimum exponents per shared prime → GCF = 2²×3 = 12.
  4. Open the GCF calculator to verify with the Euclidean algorithm.

Sieve study session

  1. Set List mode to 100 and expand the prime list.
  2. Watch the animated sieve cross off multiples.
  3. Read the density chart—note primes thin out as n grows.
  4. Try Practice mode questions on nearby candidates (51, 53, 57).

Prime Number Calculator — Check, Factorize & Explore Primes examples

Classic prime

Input

97

Output

Prime — no divisor ≤ 9

Trial division through √97 finds no factors. Common exam trick question.

Looks prime

Input

91

Output

Composite — 7 × 13

Smallest factor 7. Many students guess prime because 7 and 13 are both prime.

Factor tree

Input

360

Output

2³ × 3² × 5

Interactive tree splits 360 → 2×180 → … until all leaves are prime.

Twin primes

Input

11 and 13

Output

Both prime; gap 2

Check mode flags twin pairs when p and p+2 are both prime.

25th prime

Input

nth = 25

Output

97

The prime sequence starts 2, 3, 5, 7, …; the 25th term is 97.

Sieve list

Input

Primes ≤ 30

Output

2, 3, 5, 7, 11, 13, 17, 19, 23, 29

Ten primes below 30—matches π(30) = 10.

Algorithms used in this calculator

Small and medium n use trial division with optional step-by-step output (n ≤ 10⁶). Larger n switch to deterministic Miller–Rabin. Prime lists and ranges use the Sieve of Eratosthenes; nth prime uses incremental sieving.

Formula

Primality (trial): n prime iff ∀d ∈ [2, ⌊√n⌋], n mod d ≠ 0. Miller–Rabin: write n−1 = 2^s·d; test bases a; if a^d ≢ 1 (mod n) and a^(2^r·d) ≢ n−1 for all r < s, n is composite. Sieve: mark multiples of each prime p ≤ √N starting at p².

Assumptions

  • Inputs are non-negative integers entered as digits.
  • List upper bound ≤ 500; prime-range span ≤ 500; nth prime index ≤ 1000.
  • Step-by-step trial division available when n ≤ 1,000,000 and enabled.

Limitations

  • Not for generating RSA key-size primes (hundreds of digits)—use research-grade software.
  • Random prime in range uses rejection sampling; very sparse ranges may fail after many tries.
  • Browser BigInt and memory cap practical list/range size at 500.

Reference tables

Trial division vs Miller–Rabin (this tool)

MethodWhen usedComplexityExact?
Trial divisionn ≤ 10⁶ with steps; small checksO(√n)Yes
Miller–Rabin (deterministic bases)n > 10⁶ up to 10¹²O(k log³ n)Yes within supported bound
Sieve of EratosthenesLists and ranges ≤ 500O(N log log N)Yes

Prime vs composite quick scan

nSmallest factorClassNote
513Composite3 × 17
53PrimeNo d ≤ √53
573Composite3 × 19
59PrimeTwin with 61
917Composite7 × 13 trap

Best practices

Use divisibility shortcuts first

Eliminate 2, 3, 5, and 11 with quick rules before scanning larger trial divisors.

Enable steps for learning, disable for speed

Step-by-step trial division teaches √n stopping; large n automatically uses Miller–Rabin without flooding the UI.

Pair with GCF/LCM after factorizing

Prime exponents from factor trees map directly to greatest-common-factor and least-common-multiple formulas.

Use range mode for pattern spotting

Scan twin pairs and gaps in a bounded interval—then try Practice mode to test yourself.

Common mistakes to avoid

Calling 1 prime

Definition requires exactly two distinct positive divisors. One has only one divisor.

Testing divisors above √n

If n = a×b with a ≤ b, then a ≤ √n. Stop trial division at the floor of √n.

Assuming all odd numbers are prime

9, 15, 21, 25, 27, 33, 35, 39, 45, 49, 51, 55, 57, 63, 65, 69, 75, 77, 81, 85, 87, 91, 93, 95, 99 are odd composites below 100.

Confusing primality test with factorization

Checking whether 541 is prime stops at first factor; factorizing 360 builds the full product 2³×3²×5.

Expecting this tool to mint RSA keys

RSA needs secret primes with hundreds of digits and side-channel-safe generation—use dedicated crypto libraries.

When this tool isn't the right choice

Generating RSA keys or other cryptographic secrets

Production cryptography needs hardware-grade randomness, side-channel-safe prime generation, and primes with hundreds of digits. Use vetted libraries (OpenSSL, libsodium, or your language’s crypto module)—not a browser educational calculator capped at 10¹².

Testing numbers larger than 10¹²

This tool accepts integers up to 10¹² for primality and factorization. Beyond that, use computer algebra systems (SageMath, Mathematica, Wolfram Alpha) or research-grade factoring software.

Listing millions of primes or scanning huge intervals

List and range modes cap at 500 numbers for browser performance. For π(10⁹) tables, prime gaps at scale, or distributed sieve jobs, use specialized number-theory tools—not a client-side web calculator.

Finding GCF, LCM, or simplifying fractions directly

Prime factorization supports GCF/LCM work, but once you know the task is greatest common factor or least common multiple, the GCF calculator and LCM calculator compute the answer faster with Euclidean steps—without re-deriving every prime factor by hand.

Formal primality proofs for research or publication

Trial division and Miller–Rabin here give correct results within supported bounds, but they are not proof certificates for journals. For provable primality of record-sized candidates, use ECPP, Pocklington, or systems like Primo.

Deciding coprimality or divisibility of two numbers quickly

If the question is “do a and b share a factor?” or “does d divide n?”, checking one number for primality is the wrong workflow. Use GCF for shared factors, or test n mod d directly—primality mode only classifies a single integer.

Exploring open conjectures (twin primes, Goldbach, infinite gaps)

Practice mode and local twin/gap stats illustrate patterns for learning. They do not settle open problems or replace large-scale computation used in number-theory research.

Advertisement

Frequently Asked Questions

Is 0 or 1 prime?

Neither. Primes must exceed 1. Zero is divisible by every integer; one has exactly one positive divisor.

Why does the tool mention Miller–Rabin if trial division is taught in school?

Trial division with steps is shown for n ≤ 1,000,000. Larger accepted inputs use deterministic Miller–Rabin so the calculator stays fast and correct up to 10¹² without listing millions of divisors.

What is the sieve of Eratosthenes?

List integers 2…N, mark multiples of each prime p starting at p², and collect unmarked numbers. Our list and range modes use this; the animation shows crosses appearing in order.

What are twin primes?

Pairs (p, p+2) where both are prime—e.g. (3,5), (11,13), (17,19). Check mode flags when n is part of such a pair.

How do primes relate to RSA?

RSA public keys multiply two large secret primes. Factoring the product is hard—that hardness secures encryption. This page demonstrates the math at educational sizes only.

How many primes are below 100?

Twenty-five: the last is 97. List mode confirms π(100) = 25.

Why stop trial division at √n?

Divisors pair: if n = ab and a ≤ b, then a ≤ √n. A factor larger than √n would imply a smaller partner already tested.

How do primes appear in LCM and GCF?

Factor each input. GCF uses the lowest exponent of each shared prime; LCM uses the highest exponent across inputs.

Privacy, accuracy, and trust

Privacy

All primality tests, factorizations, and lists run in your browser. Inputs are not uploaded to EverydayTools servers.

Accuracy

Trial division and sieve outputs are exact. Miller–Rabin uses deterministic witness sets for n ≤ 10¹². Automated tests cover classics (91, 97, 360, π(100)=25).

Educational tool only—not cryptographic key generation, not a substitute for instructor grading on proofs.

Advertisement

Reviewed by EverydayTools Mathematics Team — number theory & calculator QA on 2026-07-05.

Same workflow or intent — pick the next step without leaving the site.

Frequently opened tools from the same category.

People also use

Cross-category tools others open in the same session.

Continue learning

Guides and walkthroughs that reference this tool.

Explore categories

Browse full tool collections by topic.