Prime Number Calculator

Prime numbers are the atoms of arithmetic: 2, 3, 5, 7, 11 onwards, divisible by nothing except 1 and themselves. Checking one by hand means division after division, and this page does it properly — trial division up to the square root using whole-number arithmetic only — then reports the verdict, the factor that cracked a composite open, and the next prime along.

Enter values

Whole numbers up to 10¹² — trial division up to √N

Results update as you type.

Results

Is this number prime?
97 is prime
Smallest prime factor
97 (itself)
Next prime after it
101

How is the Prime Number calculated?

One field takes a whole number up to 10¹², which is 1,000,000,000,000. The calculator rules out everything below 2 first, then even numbers, then every odd candidate up to √N; if none divides N, N is prime. For composites the first divisor found becomes the smallest prime factor, and a short scan upwards from N locates the next prime. Results refresh as you type.

Formula

N is prime when no whole number from 2 to √N divides it. Anything above the square root would have a partner below it, so that range is enough — 97 needs only 3, 5, 7 and 9 tested. The smallest factor of a composite is its first divisor, and the next prime is found by testing each odd number after N until one passes.

Example

Test 97: it is odd, so the even divisors are skipped; 3, 5, 7 and 9 all leave remainders, and the next candidate, 11, has passed √97 ≈ 9.85, so testing stops and 97 is prime. Its smallest prime factor is therefore 97 itself and the next prime is 101. Test 100 instead: it divides by 2 at once, so the smallest factor is 2 and the number is not prime.

Things to remember

Trial division is honest but linear: reaching 10¹² means up to a million checks, which this page handles comfortably; larger inputs need probabilistic tests. Establishing that a number is prime only opens the door — factorisation, highest common factors and modern cryptography all lean on how primes are distributed.

Frequently Asked Questions

How do you know if a number is prime?

Test every divisor from 2 up to the square root of the number. If none divides evenly, the number is prime — 97 needs only the odd candidates 3, 5, 7 and 9 checked before it passes. Beyond that range any factor would carry a smaller partner already rejected.

Is the number 1 considered a prime?

No. Primes are defined as having exactly two distinct factors, and 1 has only one — itself. Modern mathematics keeps 1 outside the primes so that every number factors uniquely; the calculator reports 1 as not prime and offers no smallest factor for it.

What is the smallest prime factor?

The smallest prime that divides the number. Every even number returns 2 immediately, 91 splits as 7 × 13 so its answer is 7, and a prime returns itself because nothing smaller divides it. The calculator labels that case 'itself' to keep the distinction obvious.

What is the largest known prime number?

Primes of enormous size are hunted by the Great Internet Mersenne Prime Search, and the record now runs past 24 million digits. That is far beyond any browser check — this page works up to 10¹², a range trial division sweeps in well under a second.