Math

Prime Number Calculator

Trial division to the √n bound with the 6k±1 wheel — a verdict with its evidence: how many divisions were spent, what the smallest factor is, and why the fence sits at the square root.

Prime Number Calculator

Results recalculate instantly on every keystroke. Nothing you type is transmitted.

The number
Verdict
—
Smallest factor—
The √n bound—
The method—

What this result does not account for

  • Exact verdict only up to ~1e9 — beyond that the wheel still works but slows visibly
  • No factor LIST — the smallest factor and its cofactor only
● Zero-Server Execution Updated 11 Aug 2026 Reviewed by Sana Khalid IEEE-754 Double Precision

In short: 97 is prime: the wheel tests 2, 3, 5 and 7 and every one misses, so 97 owns no divisor between 1 and itself. The fence is √97 ≈ 9.848858 — any composite must own a factor at or below it, because if both factors were larger their product would already pass n. The composite story on the same wheel: 91 falls at 7 (91 = 7 × 13) and 121 falls at 11 as a perfect square (121 = 11 × 11).

Formula

test 2 and 3, then d = 5, 7, 11, 13, … while d × d ≤ n

no hit → prime · a hit d → n = d × (n/d)

the wheel skips every multiple of 2 and 3 — the survivors are the 6k±1 numbers.

Worked Example

  1. Bound. the fence is √n: if n = a × b and both were beyond √n, their product would pass n — so a composite always betrays a factor at or below it.
  2. Wheel. test 2 and 3, then only 6k±1 candidates (5, 7, 11, 13, …): every prime beyond 3 lives on one of those residues, so nothing real is skipped.
  3. Verdict. a hit d gives the factorization n = d × (n/d) on the spot; an exhausted wheel is the definition of prime.

97 spends exactly four divisions (2, 3, 5, 7) to prove itself. 1 is neither prime nor composite — the definition wants exactly two distinct divisors, and 1 has only one. 2 is the only even prime: every other even number is divisible by 2.

Strengths & Limits Of This Model

Where this engine is strong

  • The divisions spent are printed, so the verdict carries its own evidence
  • Refuses 1 with the definition instead of guessing

Where it stops

  • No probabilistic tests (Miller-Rabin) for huge n
  • No next-prime / prime-counting helper

Risk & accuracy notice. A prime verdict from this page is exact for everything it accepts — the wheel is deterministic, not probabilistic. The honest limit is speed, not truth: near a billion the walk to the fence takes real time, and cryptographic sizes are a different sport entirely.

Practical Use Cases

Cryptography sanity

why key primes stay secret-size and trial division stays classroom-size

Fractions

a prime denominator warns you the decimal will repeat forever

Homework checks

the divisions spent are printed, not just the verdict

Methodology & Editorial Standards

Trial division on the 6k±1 wheel: test 2 and 3, then candidates 5, 7, 11, 13, … while d × d ≤ n. Every division is counted; the first hit yields d and n/d; an exhausted wheel returns prime. n ≤ 1 and non-integers are refused with the definition, not computed.

Computation runs in IEEE-754 double precision at full internal precision; rounding to two decimal places occurs strictly at the display layer, so no cumulative drift enters the result. All monetary outputs use accounting presentation — grouped thousands, two decimals, negatives in parentheses — so figures can be transcribed directly into a model or working paper. Division-by-zero and out-of-domain inputs return an em-dash rather than a misleading number.

This engine was reconciled against an independent reference implementation and hand-verified for the worked example above before release. Our full five-stage review process is published on the About Us page.

Sana Khalid Principal Front-End Engineer · ApexConverter

Numerical methods and floating-point precision engineering. Last reviewed: 11 August 2026.

Disclaimer. This calculator is provided for informational and modelling purposes only and does not constitute financial, tax, legal, medical, or engineering advice. Verify all figures with a qualified professional before acting on them.


Prime Number Calculator — 9 Expert FAQs

9 analyst-written answers to the questions practitioners actually ask — optimised for voice and answer-engine retrieval.

Why is it enough to test up to the square root?

If n = a × b and both a and b were greater than √n, their product would be greater than n — impossible. So every composite number owns at least one factor at or below √n, and a wheel that reaches √n without a hit has ruled that factor out. Testing beyond the root can only re-find the cofactors you already met on the way up.

Is 1 a prime number?

No — and not a composite either. A prime has exactly two distinct divisors, 1 and itself; 1 has only one. The exclusion is not pedantry: if 1 counted as prime, every number would have many factorizations and the fundamental theorem of arithmetic — one prime factorization per number — would collapse.

Why skip 9, 15, 21 and the other multiples of 3 in the wheel?

The 6k±1 wheel tests only numbers one below or one above a multiple of 6, because every prime beyond 3 has that shape: any number of the form 6k, 6k+2 or 6k+4 is even, and 6k+3 is divisible by 3. Composite 6k±1 numbers still get tested — 25, 35, 49 are all on the wheel — but their prime factors arrive earlier and catch them.

Is 2 really the only even prime?

Yes. Every even number beyond 2 is divisible by 2, so none of them can be prime. 2 keeps the crown because its only divisors are 1 and 2. It is also the prime that makes every even number’s factorization start the same way.

What does the calculator print for a composite?

The smallest factor the wheel found, the cofactor it implies (n = d × n/d), and how many divisions were spent before the hit. For 91 that is four divisions and the factorization 91 = 7 × 13. For a perfect square like 121 the two factors meet at the fence itself: 121 = 11 × 11.

Why not test only prime divisors?

You can — it is faster for big n, because a composite candidate is always caught by one of its smaller prime factors first. But it needs a prime list up front (a sieve), and for classroom-size numbers the wheel version is within a breath of it while needing no table at all. This page stays table-free on purpose.

Could I test up to the cube root instead?

No — that is a genuine trap. 143 = 11 × 13 has its smallest factor at 11, but the cube root of 143 is only about 5.2, so a cube-root fence stops before 11 and wrongly clears the number. The square root is not an optimization you can tighten; it is the exact point where one of every factor pair is guaranteed to have shown up.

How big a number can this page test?

Comfortably into the hundreds of millions — the wheel only walks to √n, so a 9-digit number costs a few thousand divisions at most. Cryptographic primes (hundreds of digits) are out of reach of trial division by design; their testers use probability, not certainty.

Does the page tell me HOW the verdict was reached?

Yes — that is the point of printing the evidence. The bound card shows the √n fence, the factor card shows what fell or that nothing did, and the verdict names the divisions spent. A verdict without its divisions is a guess with good manners.

Related Math Engines