🔢 Prime Number Checker

Check whether a number is prime using trial division up to the square root. Supports large integers via BigInt.

Is this number prime?

About the Prime Number Checker

This prime number checker runs entirely in your browser. Enter any non-negative integer and it tells you whether the number is prime, plus the smallest divisor when it is not. The algorithm uses trial division up to the square root and BigInt arithmetic so that very large integers stay exact.

How primality testing works

  • Definition — A prime number is a natural number greater than 1 that has exactly two positive divisors: 1 and itself.
  • Trial division — To test n, try dividing by every integer d from 2 up to ⌊√n⌋. If any d divides n evenly, n is composite; otherwise n is prime.
  • Why √n is enough — If n = a × b with both a, b > √n, then a × b > n, which is impossible. So at least one factor must be ≤ √n.
  • Optimizations — Handle 2 separately, then test only odd divisors (3, 5, 7, …). This halves the work.

How to use the checker

  1. Type a non-negative integer into the input field.
  2. Click Check to see the verdict below the button.
  3. If the number is composite, the smallest divisor (other than 1) is shown as a hint.

Frequently asked questions

Is 1 prime? No. By modern definition, primes must be greater than 1, so 1 is neither prime nor composite.

Is 2 prime? Yes. It is the only even prime; every other even number is divisible by 2.

How large can the input be? BigInt keeps the value exact regardless of size, but trial division gets slower as √n grows. Numbers up to about 12 digits return instantly; very large inputs may take noticeably longer.

Is my input stored or uploaded? No. Everything happens in your browser. Your numbers are never sent to a server.