Check whether a whole number is prime, and see its smallest divisor when it is not.
Example
97 is prime, and so is 7,919, the 1,000th prime. 91 is not prime because 91 = 7 × 13, and 221 is divisible by 13 since 221 = 13 × 17.
Calculation method
The checker handles 2 and even numbers first, then tries odd divisors up to the square root of your number. If a factor existed above that point, its partner would be smaller and would already have been found. Even 999,999,937, the largest prime below one billion, needs at most about 15,800 trial divisions, so the answer appears almost instantly.
Important notes
Enter a whole number from 2 to 1,000,000,000. The number 1 is not prime, because a prime has exactly two positive divisors, and decimals are rejected since primality applies to integers. When a number is composite, the result names its smallest divisor greater than 1.
What the checker tests
Enter a whole number from 2 to 1,000,000,000. A prime has exactly two positive divisors, 1 and itself. 97 is prime, and so is 7,919, the 1,000th prime. When a number is not prime, the result names its smallest divisor greater than 1: 91 is divisible by 7 because 91 = 7 × 13. The number 1 is not prime, and 2 is the only even prime, so every other even number is reported as divisible by 2.
Why testing stops at the square root
If a number has a factor larger than its square root, the matching factor must be smaller than the square root and would already have been found. The checker therefore tests odd divisors only up to that point. For 221 it stops as soon as it reaches 13, because 221 = 13 × 17. Even 999,999,937, the largest prime below one billion, needs at most about 15,800 odd trial divisions, so the answer appears almost instantly in the browser.
Tricky composites and limits of this tool
Numbers that look prime can hide small factors. 561 is the smallest Carmichael number, which passes some quick probabilistic tests, yet it is divisible by 3. A digit-sum check works for 3: 5 + 6 + 1 = 12, which is divisible by 3. Decimals and numbers outside the range are rejected. This tool is designed for learning and everyday checks, not for generating the very large primes used in cryptography, which require different algorithms and secure random numbers.
Worked examples| Input | Result |
|---|
97 | ✓ |
7919 | ✓ |
999999937 | ✓ |
91 | ÷ 7 |
221 | ÷ 13 |
561 | ÷ 3 |
Frequently asked questions
Why does a number that looks prime turn out not to be?
Small factors hide easily. 561 is the smallest Carmichael number, which passes some quick probabilistic tests, yet it is divisible by 3. A digit-sum check catches that one: 5 + 6 + 1 = 12, which is divisible by 3. The tool always tests divisors directly, so its answer is exact.
Why stop testing at the square root?
Because factors come in pairs. For 221 the search stops as soon as it reaches 13, since 221 = 13 × 17 and any larger factor would already have been paired with a smaller one. That is what keeps the check fast even for numbers close to one billion.
Can I use this for cryptography?
No. This tool is built for learning and everyday checks up to 1,000,000,000. The primes used in encryption are hundreds of digits long and are generated with probabilistic tests and secure random numbers, which trial division cannot do in any reasonable time.