UtilityToolsLab

© 2026 UtilityToolsLab. Built and maintained by the UtilityToolsLab Team.

Free eBooks·About·Changelog·Privacy Policy·Terms of Service·Report a bug
HomeNumber & Base ToolsPrime Checker

Related Tools

Matrix CalculatorRandom NumbersDice RollerFibonacci Generator

Prime Number Checker

Check whether any positive integer is prime, with the full prime factorisation when it is not. Trial division to ⌈√n⌉ — deterministic and exact.

You Might Also Like

All Number & Base Tools

Matrix Calculator

Add, subtract, multiply, transpose, and find the determinant or inverse of a 2x2 or 3x3 matrix. No data ever leaves your device.

Random Numbers

Draw whole numbers from any range using your device's cryptographic random source, with unique-values mode and the modulo bias rejected rather than ignored.

Dice Roller

Roll d4 through d100 with standard dice notation like 2d6+3, a running history, and cryptographically random results. No physical dice required.

Fibonacci Generator

Generate the Fibonacci sequence up to F(200) with exact BigInt precision. Shows golden-ratio convergence, a visual bar chart, and copy as CSV or lines.

Paste any positive integer and the Prime Number Checker tells you in one click whether it is prime. If it is not, you also get the complete prime factorisation, so 91 does not just return “not prime” but shows 91 = 7 × 13, and you can see immediately which factors you were missing. The result copies as a sentence ready to paste into a report or a chat thread.

Pressing Load Sample loads 9999991 on the first click, the largest prime below ten million. That number passes the trial-division limit of √9999991 ≈ 3163 without finding a factor, which is the fastest way to see both the algorithm and the result side by side. Subsequent clicks cycle through a Mersenne prime (131071 = 2¹⁷ − 1), a classic trick question (91 = 7 × 13), the Fermat pseudoprime 341, and other instructive cases.

Worked Example: A Seven-Digit Prime

  1. The tool handles 1 separately: it is neither prime nor composite. It is a unit, and the reason is shown on screen so the verdict does not look like a bug.
  2. 2 and 3 are confirmed prime directly before any division is attempted, because the 6k±1 wheel that follows skips them as special cases.
  3. Any number divisible by 2 or 3 is flagged immediately without reaching the main loop. Most even numbers are eliminated here in a single modulo operation.
  4. The remaining candidates are tested in the form 6k ± 1(5, 7, 11, 13, 17, 19 …) up to ⌈√n⌉. Every prime above 3 fits this form; numbers that do not are already caught by step 3. This makes the loop roughly three times faster than testing every odd number.
  5. If no factor is found below √n, the number is prime. For 9999991 that means checking 528 candidates, not five million.

Tricky Inputs and Known Edge Cases

  • Entering a decimal such as 97.5 returns “Please enter a positive integer — whole numbers only, no decimals or signs.”
  • Values above 9 007 199 254 740 991 (2⁵³ − 1) exceed JavaScript's safe-integer range. The tool catches this before running and reports it, rather than silently producing a wrong answer.
  • The Fermat pseudoprime 341 = 11 × 31 passes the naive test that many student implementations use (checking whether 2³⁴⁰ ≡ 1 mod 341) but this tool divides directly, so it correctly identifies 341 as composite on the first Load Sample cycle that reaches it.
  • Repeated exponents are rendered with superscripts: entering 72 shows 72 = 2³ × 3², not2 × 2 × 2 × 3 × 3.
  • Session history keeps the last 20 numbers you checked, newest first. Clicking any row re-runs that number so you can re-examine a result without re-typing it.

Accuracy and the Safe-Integer Ceiling

Probabilistic methods like Miller-Rabin are needed when testing numbers above roughly 10¹⁵. Below that threshold, trial division up to √n is exact, gives zero false positives, and for any value a person would plausibly type runs in well under a millisecond. The component does not need a primality certificate or a probabilistic witness. The loop either finds a factor or exhausts every possible one, and the 2⁵³ − 1 ceiling is stated on screen so there is no silent failure on large inputs.