number theory calculators

Prime Number Checker

Instantly determine whether any positive integer is a prime number. Use it for number-theory homework, cryptography key checks, or satisfying mathematical curiosity.

About this calculator

A prime number is a positive integer greater than 1 that has no divisors other than 1 and itself. The checker uses a trial-division algorithm optimised by the fact that all primes greater than 3 are of the form 6k ± 1. The algorithm first rules out numbers ≤ 1 (not prime), then handles 2 and 3 as special cases, then eliminates any even number or multiple of 3. After that, it tests divisors of the form 6k − 1 and 6k + 1 up to √n. If no divisor is found, the number is prime. The key insight is that you only need to test up to √n because if n has a factor larger than √n, it must also have a corresponding factor smaller than √n. This makes the algorithm roughly O(√n / 3) in time.

How to use

Let's check whether 97 is prime. Enter 97 in the Number to Check field. The calculator first confirms 97 > 3 and that 97 is not divisible by 2 or 3. It then tests divisors of the form 6k ± 1: k=1 gives 5 and 7; k=2 gives 11 and 13; … up to k=3 giving 17 and 19 — since 19² = 361 > 97, the loop stops. None of those values divide 97 evenly, so the result is Prime. By contrast, entering 91 reveals it is not prime because 91 = 7 × 13, detected when i = 7.

Frequently asked questions

Why is 1 not considered a prime number?

The number 1 is excluded from the primes by definition because including it would break the Fundamental Theorem of Arithmetic, which states that every integer greater than 1 has a unique prime factorisation. If 1 were prime, factorizations would no longer be unique — for example, 6 could be written as 2 × 3, or 1 × 2 × 3, or 1 × 1 × 2 × 3, and so on. By convention, 1 is called a unit, not a prime.

How do you check if a very large number is prime?

For small numbers, trial division up to √n is fast and exact. For very large numbers (hundreds of digits), more sophisticated algorithms are used: the Miller-Rabin probabilistic test quickly identifies likely primes with controllable error probability, and the AKS deterministic test proves primality in polynomial time. Modern cryptographic systems like RSA rely on generating large primes with hundreds of digits; they use repeated Miller-Rabin tests until confidence is essentially certain.

What are twin primes and why are they significant?

Twin primes are pairs of prime numbers that differ by exactly 2, such as (11, 13), (17, 19), or (41, 43). They are significant because the Twin Prime Conjecture — one of the oldest unsolved problems in mathematics — proposes that infinitely many such pairs exist, but this has never been proven. In 2013, Yitang Zhang made a landmark breakthrough by proving there are infinitely many prime pairs with a gap of at most 70 million, a bound since reduced dramatically, but the conjecture itself remains open.