AI Tools Free

Prime Number Checker

Enter any whole number from 0 to 1,000,000,000 into this prime number checker to see if it is a prime number or composite. When a number is composite, the tool shows its smallest prime factor and matching cofactor (n = p x (n / p)) directly in your browser.

Free to useNo sign-upRuns in your browser
Enter your details

Enter the inputs, then select Calculate result.

Your result
Enter your details

Result will appear here

How this prime number checker tests primality up to 1 billion

A prime number is an integer greater than 1 whose only positive divisors are 1 and itself. This checker evaluates primality up to 1,000,000,000 using deterministic square-root trial division in client-side JavaScript.

When you submit an integer x, the calculator first checks if x < 2 (returning Not prime: 0 or Not prime: 1) or x = 2 (returning Prime: 2). For any integer above 2, it tests divisibility by p = 2 and then odd divisors p = 3, 5, 7, 9, ... while p * p <= x.

If any candidate divides x with zero remainder, the loop stops immediately and returns Not prime: x = p x (x / p). Because divisors are tested in ascending order, the first factor p found is always the smallest prime factor of x. Since sqrt(1,000,000,000) is 31,622.77, even a 9-digit prime requires at most 15,811 division checks.

Trial division workflow testing odd divisors up to floor(sqrt(n)) to classify an integer as prime or composite.
Trial division checks 2 and odd integers up to floor(sqrt(n)) to verify primality or find the smallest prime factor.

Prime numbers under 100 and look-alike odd composites table

Compare all 25 prime numbers below 100, common odd composite numbers that pass quick divisibility rules, and the largest primes below powers of 10.

Category or rangeNumbers in groupPrime status and factor notes
Primes from 2 to 192, 3, 5, 7, 11, 13, 17, 198 primes (2 is the only even prime number)
Primes from 23 to 4723, 29, 31, 37, 41, 43, 477 primes
Primes from 53 to 7353, 59, 61, 67, 71, 736 primes
Primes from 79 to 9779, 83, 89, 974 primes (25 prime numbers total below 100)
Divisible-by-3 odd composites under 10051 (3 x 17), 57 (3 x 19), 87 (3 x 29), 93 (3 x 31)Composite (digit sum is a multiple of 3)
Two-digit look-alike composite91Not prime: 91 = 7 x 13 (passes 2, 3, and 5 checks)
Three-digit multiples of 7119 (7 x 17), 133 (7 x 19), 161 (7 x 23), 203 (7 x 29)Composite (smallest prime factor is 7)
Three-digit multiples of 11 and 13121 (11 x 11), 143 (11 x 13), 169 (13 x 13), 187 (11 x 17), 221 (13 x 17)Composite (requires testing primes 11 and 13)
Classic 4-digit Euler composite1001Not prime: 1001 = 7 x 143 (factors into 7 x 11 x 13)
Largest primes below powers of 10997 (< 1,000), 9973 (< 10,000), 999983 (< 1,000,000), 999999937 (< 1,000,000,000)Verified prime benchmarks within tool range

How to check if a number is prime step by step

Follow these three steps to test whether any non-negative integer up to 1 billion is prime or composite.

Enter a whole number

Type your target integer into the Integer to check box (pre-filled with 97). You can test small homework numbers like 91 or 9-digit integers up to 1000000000.

Integer to check
Prime Number Checker input field set to 97 with whole-number range instructions.
Enter any non-negative whole number from 0 to 1,000,000,000.

Avoid commas and decimals

Enter plain digits without thousand-separator commas or decimal points. Negative integers, decimals, and numbers above 1,000,000,000 trigger an input range validation message.

Primality output
Prime Number Checker output card displaying Prime: 97 after testing divisors up to 9.
The result card outputs Prime: n or Not prime: n = p x (n / p) with the smallest prime divisor.

Run the primality check

Click Calculate result to display Prime: n or Not prime: n = p x (n / p). You can copy the output string or download result.txt for your notes.

Result and export
Prime Number Checker workspace showing the input integer, primality status, and Copy result and Download buttons.
Copy the primality result to your clipboard or download it as a plain-text file.

Worked prime number check examples

These three examples show how the square-root bound floor(sqrt(n)) verifies primes and exposes composite numbers.

Testing a two-digit prime (97)

Because floor(sqrt(97)) = 9, you only need to check prime divisors up to 9, which are 2, 3, 5, and 7. None of those four primes divide 97 evenly, so the calculator outputs Prime: 97.

Testing 97 by checking prime divisors 2, 3, 5, and 7 up to floor(sqrt(97)) = 9.
Testing primes up to floor(sqrt(97)) = 9 confirms 97 has no divisors between 2 and 9.

Catching a look-alike odd composite (91 and 1,001)

The integer 91 ends in 1 and its digits sum to 10, so it is not divisible by 2, 3, or 5. Dividing by 7 reveals 91 / 7 = 13, so the checker outputs Not prime: 91 = 7 x 13. Likewise, 1001 returns Not prime: 1001 = 7 x 143.

Factoring the odd composite 91 into 7 x 13 after it passes divisibility checks for 2, 3, and 5.
Dividing 91 by 7 exposes 91 = 7 x 13, catching the classic two-digit look-alike composite.

Verifying the largest prime below 1 billion (999,999,937)

For n = 999999937, the square-root limit is floor(sqrt(999999937)) = 31622. Testing 2 and all odd numbers from 3 to 31621 finds zero exact divisors, returning Prime: 999999937 in milliseconds.

Verifying 999,999,937 as prime by testing odd divisors up to floor(sqrt(999999937)) = 31,622.
Even a 9-digit prime like 999,999,937 requires testing odd divisors only up to 31,621.

What your prime or composite result means

Understand how to read the factor pair returned for composite numbers and why 0 and 1 are excluded.

When your integer is composite, the result line Not prime: n = p x (n / p) gives you the smallest prime divisor p and the cofactor n / p. To break n / p all the way down into prime powers, enter the number into the Prime Factorization Calculator, or list every positive factor in ascending order with the Divisors Calculator.

When you enter 0 or 1, the tool returns Not prime: 0 or Not prime: 1. A prime number must have exactly two distinct positive divisors (1 and itself); 1 has only one divisor, and 0 is divisible by every nonzero integer.

Reading the smallest prime divisor p and cofactor n / p returned for composite integers.
Composite outputs show the smallest prime factor p and matching cofactor n / p.

Quick divisibility rules before checking a prime number

Use these mental shortcuts when learning how to check whether a number is prime on paper.

Any integer greater than 5 that ends in 0, 2, 4, 5, 6, or 8 is divisible by 2 or 5 and can be ruled out at a glance. Next, add the digits of the number together: if the digit sum is a multiple of 3 (for example, 1 + 1 + 1 = 3 for 111), the number is divisible by 3.

For numbers that pass the 2, 3, and 5 checks, test 7, 11, 13, 17, 19, and 23 up to floor(sqrt(n)), or check exact remainders with the Modulo Calculator. If you are comparing two integers to see whether they are relatively prime (coprime), use the GCF Calculator.

Mental divisibility checks for last digits (0, 2, 4, 5, 6, 8) and digit sums divisible by 3.
Rule out multiples of 2, 3, and 5 using last-digit and digit-sum checks before testing primes 7, 11, and 13.

Frequently asked questions about checking prime numbers

Answers to common questions about prime numbers, the square-root trial division rule, 0 and 1, and tricky composite numbers.

Why is 1 not a prime number?

By definition, a prime number has exactly two distinct positive divisors: 1 and the number itself. The integer 1 has only one positive divisor (1). Excluding 1 from the primes ensures the Fundamental Theorem of Arithmetic holds, so every integer greater than 1 has a single unique prime factorization.

Why is 2 the only even prime number?

Dividing 2 by 1 or 2 leaves zero remainder, with no other positive integers in between, which makes 2 prime. Every larger even integer is a multiple of 2 (4, 6, 8, 10, ...), so 2 is always a third factor alongside 1 and the number itself.

Why do you only test divisors up to the square root of n?

If an integer n > 1 can be factored as n = a x b with 1 < a <= b, then multiplying a <= b by a gives a^2 <= a x b = n, so a <= sqrt(n). If no integer from 2 up to floor(sqrt(n)) divides n evenly, no matching cofactor b can exist above sqrt(n) either, proving n is prime.

Is 91 a prime number or composite?

The number 91 is composite because 91 = 7 x 13. It is the most frequently missed two-digit composite in school math tests because it is odd, does not end in 5, and its digits add up to 10 (not divisible by 3).

How many prime numbers are there between 1 and 100?

There are exactly 25 prime numbers between 1 and 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, and 97. All four of these subsets are listed in the lookup table above.

Can a negative integer or decimal be a prime number?

No. Primality is defined on positive integers greater than 1. Fractions and decimals are not integers, and negative integers like -7 are classified in ring theory as prime associates (-1 x 7) rather than standard positive prime numbers.

Check whether your number is prime now

Return to the input box above to test another integer up to 1,000,000,000.

Calculate result