Advertisements

headerup to 320x100 / 728x90

Prime Number Checker

Check if a number is prime

Prime Number Checker

Use a single integer field and get a clear yes/no answer.

Input
Focused controls for small conversions and calculations.
Results
Readable cards for unit-heavy output, with raw output kept for special cases.
Enter a value above or tap a sample to see structured results.
Advertisements

content bottomup to 300x250

What is Prime Number Checker

Last reviewed:

Prime Number Checker determines whether a positive integer is prime — divisible only by 1 and itself. For small inputs (under 10^9) it uses deterministic trial division; for larger inputs it uses the Miller–Rabin primality test with witness bases proven correct up to 3.3 × 10^14 and probabilistically correct above that.

The tool also returns the prime factorization for composite numbers, the list of primes up to a chosen limit (Sieve of Eratosthenes), and the next prime after your input — useful for cryptography exercises and number-theory homework.

Why use it

  • Verify a candidate prime for RSA key generation or Diffie–Hellman group selection.
  • Check homework problems or generate prime-factorization examples for students.
  • Find the next prime above a chosen integer — useful for hash-table sizing to minimize collisions.

Features

  • Deterministic trial-division check for inputs under 10^9 — always exact, no probability involved
  • Miller–Rabin probabilistic test for inputs up to 2^64 with a 1-in-10^15 false-positive rate using 12 witnesses
  • Prime factorization output for composite numbers, showing prime factors and their multiplicities
  • Sieve of Eratosthenes mode — list all primes up to a chosen upper bound (up to 10,000,000)
  • Next-prime and previous-prime utilities for quick navigation around your input

How to use Prime Number Checker

  1. Enter the number. Type any positive integer. The tool accepts values up to 2^64 (about 1.8 × 10^19).
  2. Review the primality result. The result shows 'Prime' or 'Composite' instantly. For 'Composite', the prime factorization appears below (e.g., 12 = 2² × 3).
  3. See the test used. For small inputs, the tool shows the list of trial divisors that ruled primality in or out. For large inputs, it shows the Miller–Rabin witnesses and iteration count.
  4. Navigate primes (optional). Click 'Next prime' or 'Previous prime' to jump to the nearest prime above or below your input — useful for finding safe primes or hash-table sizes.
  5. Generate prime lists (optional). Switch to Sieve mode and enter an upper bound to get the full list of primes up to that value, formatted as a comma-separated array or a one-per-line list.

Example (before/after)

Prime Number input

Start with the prime Number input you want to process in Prime Number Checker.

Prime Number output

Get a prime Number result from Prime Number Checker that is ready to review, copy, and reuse in the next step of your workflow.

Common errors

Unsupported input

The tool may reject input that does not match the expected content, structure, or file type.

Fix: Confirm the tool input requirements and paste the correct type of data.

Incomplete values

Missing fields or partial content can block processing or produce weak results.

Fix: Provide the full required input before running the tool.

Copying placeholder content

Sample or placeholder values can lead to output that looks valid but is not ready for real use.

Fix: Replace placeholders with your actual values before relying on the result.

FAQ

Is the Miller–Rabin test good enough for cryptography?

For key-sized primes (1024+ bits), production cryptography libraries use Miller–Rabin with 40+ rounds, giving a false-positive rate below 2^-80. This tool uses 12 witness bases, which is deterministic up to 3.3 × 10^14 and delivers ~2^-36 false-positive above that — enough for study and verification, but you should use a proper library (OpenSSL, BoringSSL) for actual key generation.

How big a number can the tool handle?

Up to 2^64 − 1 (18,446,744,073,709,551,615). Above that, primality testing needs arbitrary-precision arithmetic (BigInt), which would slow the browser down for the test frequencies we expect. For 1024-bit or larger primes, use a CAS like WolframAlpha or a scripting environment with a GMP binding.

What's the difference between trial division and Miller–Rabin?

Trial division tries every prime up to √n as a divisor — exact but slow beyond 10^9. Miller–Rabin tests a few randomized witnesses; for n ≥ 2, if any witness 'fails', n is definitely composite. With enough witnesses, the probability of missing a composite is negligible. Miller–Rabin is how real-world primality testing is done.

Does 'Composite' output show all prime factors?

Yes. The factorization output lists every prime factor and its multiplicity. For example, 360 returns 'Composite — 2³ × 3² × 5'. For very large composites with no small factors, the tool uses Pollard's rho to extract factors before handing off to Miller–Rabin on each factor.

How is the Sieve of Eratosthenes implemented?

Standard sieve with odd-only optimization: a boolean array of length n/2 is initialized, then for each prime p up to √n, all odd multiples of p are marked composite. The sieve handles an upper bound of 10,000,000 in roughly 200 ms on a modern browser — memory cost scales linearly with the bound.

Why is 1 not considered prime?

By definition, a prime has exactly two distinct divisors: 1 and itself. 1 has only one divisor (itself), so it doesn't meet the definition. Excluding 1 is also the only convention that makes the Fundamental Theorem of Arithmetic — unique prime factorization — work without special cases. The tool returns 'Not prime' for 1 and 0, and 'Invalid' for negatives.