Calculatrixe

Prime Number Checker

Check whether a whole number is prime. Composite numbers are factored into primes, with their divisors listed, and every result shows the nearest primes below and above. It works for numbers of up to 24 digits.

Inputs

Any whole number from 0 up to 24 digits.

Result

Enter a whole number to test.

The calculation runs in this browser tab. Nothing you enter is uploaded, saved or logged.

What is a prime number?

A prime number is a whole number greater than 1 whose only divisors are 1 and itself: 2, 3, 5, 7, 11, 13… A whole number greater than 1 that is not prime is composite, and can be written as a product of primes in exactly one way (the fundamental theorem of arithmetic): 360 = 2³ × 3² × 5.

Two special cases cause frequent confusion. 2 is the only even prime. And 1 is not prime, because a prime must have exactly two divisors and 1 has only one; it is not composite either. 0 is neither, as every number divides it.

How to use the Prime Number Checker

  1. Type a whole number from 0 up to 24 digits.
  2. The verdict appears immediately: prime, composite, or neither (for 0 and 1).
  3. For a composite number, read its prime factorisation, smallest prime factor and divisors.
  4. Check the previous and next primes to see where the number sits. Copy result copies the verdict.

Formula

Definition
n is prime ⇔ n > 1 and its only divisors are 1 and n
Trial division bound
if n has no divisor from 2 to √n, then n is prime
Number of divisors
if n = p₁^a × p₂^b × …, then d(n) = (a + 1)(b + 1)…

Trial division is enough for small numbers, but too slow for large ones. For big inputs the calculator uses the Miller–Rabin test with twelve fixed bases, which is proven to give the right answer for every number below 3.3 × 10²⁴, so there is no probability involved.

Factorisation uses trial division by every prime up to 1,000,000. That completes the factorisation of any number below 10¹² and of most larger numbers.

Worked example

91 looks prime but is not: it is 7 × 13. These are the results the checker gives:

QuestionResult
Input: Whole number91
Result91 is a composite number
Prime factorisation7 × 13
Smallest prime factor7
Number of divisors4
All divisors1, 7, 13, 91
Previous prime89
Next prime97

Assumptions and limits

  • The primality verdict is exact for every number accepted (up to 24 digits).
  • A large composite number whose prime factors all exceed 1,000,000 cannot be split by trial division. It is correctly reported as composite, with the remaining factor shown as “not factored further”, and the divisor list is not given in that case.
  • Only whole numbers from 0 are accepted. Negative numbers are not usually called prime.
  • Lists of all divisors are shown only when a number has at most 64 of them.

Frequently asked questions

How do I know if a number is prime?

Try dividing it by every prime up to its square root; if none divides it exactly, it is prime. For 97 the primes up to 9 are 2, 3, 5 and 7, none of which divides 97, so 97 is prime. For large numbers use a tool like this one.

Is 1 a prime number?

No. A prime has exactly two distinct divisors, 1 and itself, and 1 has only one divisor. Excluding 1 also keeps factorisation into primes unique.

Is 2 a prime number?

Yes, and it is the only even prime: every other even number is divisible by 2 and so has at least three divisors.

What is the largest number this checker can test?

Numbers up to 24 digits. Within that range the Miller–Rabin test with twelve bases gives a certain answer, not a probable one.

What does “not factored further” mean?

The number is composite, but after removing all prime factors up to 1,000,000 the remaining part is itself composite with large prime factors, which trial division cannot find. The verdict is still correct; only the complete factorisation is missing.

How many primes are there?

Infinitely many, as Euclid proved around 300 BC. They thin out as numbers grow: about one number in 14 near 10⁶ is prime, and one in 28 near 10¹². The previous and next prime shown by the checker let you see the gap around your number.