Check prime

Classify an integer as prime or non-prime by testing divisors through its square root.

freeworks offlinenothing uploaded
ToolPrime Checker
Input
Output

How it works

Trial divisors run from 2 through √n; finding none identifies a prime because every composite has a factor no greater than its square root. Safe-integer input keeps modulo tests exact.

  • The square-root bound limits trial work.
  • Values below two are not prime.

Worked example

Check Prime
Check if 97 is a prime number
Input
											97
										
Output
												97 is a prime number
											

When to use this

Number-theory exercises classify integers, cryptography lessons screen candidates, and coding problems demonstrate divisor bounds.

Edge cases

  • 0 and 1 are not prime.
  • 2 is the only even prime.
  • Values above JavaScript’s safe-integer limit are rejected.