Math

Prime number checker

See whether a whole number is prime, composite, or neither.

Free to useNo sign-upCalculated in your browser

Whole number

From 0 through 18446744073709551615. Digits only.

A nonnegative whole number. No commas or decimals.

The number stays in this browser.

Prime, composite, or neither

Zero and one are neither prime nor composite. A prime has exactly two positive divisors.

What a prime number is

A prime number is a whole number greater than 1 whose only positive divisors are 1 and itself. Two, 3, 5, 17, and 97 are prime. Four is not: it is 2 times 2.

A composite number is a whole number greater than 1 that can be written as a product of two integers that are both greater than 1. Twenty-one is composite because 3 times 7 is 21. One hundred, 561, 1105, and 1729 are composite as well.

Why zero and one are neither

Zero is not prime. Every integer divides zero, so zero does not have exactly two positive divisors. Zero is not composite either, because a composite number is a product of integers that are both greater than 1.

One is not prime. It has exactly one positive divisor, itself. OpenStax Prealgebra builds factor lists from whole numbers greater than 1. One is not composite, because it is not a product of two integers greater than 1.

How this page decides

The checker accepts a whole number from 0 through 18,446,744,073,709,551,615. That last value is the largest unsigned 64-bit integer. The next integer, 18,446,744,073,709,551,616, is rejected. So are decimals, negative signs, commas, and scientific notation. The digits are read with integer arithmetic, not with a floating-point number, so a 20-digit value is not rounded.

For every accepted integer above 1, the page uses a deterministic Miller–Rabin test. The witnesses are 2, 325, 9375, 28178, 450775, 9780504, and 1795265022. CP-Algorithms records that this set decides primality for every integer below 2^64. The result is certain inside the range above. It is not a random or probabilistic test.

The page may also name a divisor at or below 97 when it finds one. For 21, that divisor is 3. Naming one divisor is not a complete factorization. If no divisor that small is found, the page still does not treat that search as a primality proof. 341,550,071,728,321 and 3,825,123,056,546,413,051 are composite even though neither has a divisor at or below 97. 18,446,744,073,709,551,557 is prime. 18,446,744,073,709,551,615 is composite.

What belongs on another page

Shared factors of two or more numbers belong on the GCF calculator. A common multiple belongs on the LCM calculator. This page does not factor a number completely, and it does not test integers above the unsigned 64-bit maximum.

Frequently asked questions

Is 1 a prime number? No. A prime has exactly two positive divisors, 1 and itself. One has only one positive divisor, so it is neither prime nor composite.

Does a missing small factor mean the number is prime? No. The small-divisor search stops at 97. Primality inside the supported range comes from the deterministic Miller–Rabin test.

Sources & review

Last reviewed: . The formula is reproduced above so you can check the math independently.

How we check calculations and describe their limits

Deterministic primality for whole numbers from 0 through 18446744073709551615. Not a complete factorization.

Accessibility and student privacy

Our accessibility target is WCAG 2.1 AA. We use automated checks for keyboard operation, narrow layouts and readable alternatives to charts. Keyboard and screen reader behavior can vary by device and browser.Report an accessibility issue.

These tools have no ads, affiliate offers or sponsored content. No account is needed. Calculations run in your browser; your inputs and results are not sent to us or to analytics. Google Analytics may be used to measure site usage. See Privacy & analytics for details and how to turn it off.