Skip to content

Prime Number Checker

What do you want to do?

Whole numbers below 318,665,857,834,031,151,167,461, typed as digits so even very large numbers are read exactly. Decimals and fractions are not prime or composite, so the checker asks for a whole number.

Whole numbers from 1 to 1,000,000,000,000 (one trillion). The checker shows every division step, down to the prime factors.

Range to search

Ranges up to 1,000,000 wide, listing at most 10,000 primes. The upper bound must be at most one trillion.

Answer

Working, step by step

      This checker gives exact prime number answers with the working shown, for homework and everyday mathematics. It tests whole numbers below 318,665,857,834,031,151,167,461 exactly, factors numbers up to one trillion, and lists at most 10,000 primes per range. It is an educational aid: if an answer looks surprising, check the steps against your textbook or teacher.
      Quick answer: 97 is prime: it is not divisible by 2, 3, 5, or 7, the only primes up to its square root. This checker also factors numbers into primes and lists primes in a range, with every step shown.

      Last reviewed: 20 November 2026. Reviewed every 180 days; next review due 19 May 2027.

      How to use the Prime Number Checker

      Pick one of the three modes at the top of the checker. "Is it prime?" tests a single whole number and tells you whether it is prime, composite, or neither. "Factor a number" breaks a whole number down into its prime factors and shows every division step. "Primes in a range" lists every prime number between two bounds and counts them. The answer updates as you type, and every result shows its working step by step, so you can follow exactly how the answer was reached.

      In check mode, type any whole number below 318,665,857,834,031,151,167,461. Large numbers are typed as digits and read exactly, with no rounding, so even a 20-digit number is tested precisely. If the number is composite, the checker shows its smallest factor and the other factor it pairs with. If the number is prime, the checker says which method proved it: definition for 2, trial division for numbers up to 100, and the Miller-Rabin test for larger numbers.

      Factor mode accepts whole numbers from 1 up to 1,000,000,000,000 (one trillion). The result shows the prime factorization with exponents, for example 360 = 2³ × 3² × 5, plus the full division chain that produced it. Range mode searches ranges up to 1,000,000 wide, lists at most 10,000 primes, and takes an upper bound of at most one trillion. If you enter the bounds the wrong way round, the checker swaps them and tells you it did so.

      How it works

      What makes a number prime

      A prime number is a whole number greater than 1 whose only factors are 1 and itself. The number 7 is prime because the only whole numbers that divide it exactly are 1 and 7. A composite number has more than two factors: 16 is composite because its factors are 1, 2, 4, 8, and 16. The smallest prime is 2, and it is the only even prime number, because every other even number is divisible by 2 as well as by 1 and itself. The first few primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29.

      Primes get rarer as numbers grow, but they never run out. There are 25 prime numbers below 100, 168 below 1,000, 1,229 below 10,000, 9,592 below 100,000, and 78,498 below one million. That thinning out is why testing a large number takes real work: a 12-digit number might need checking against thousands of possible divisors before it can be called prime.

      Why 1 is not prime

      The number 1 is neither prime nor composite. A prime number must have exactly two factors, and 1 has only one factor, itself. A composite number must have more than two factors, and 1 does not qualify there either. Zero is in the same position: it can be divided exactly by every whole number, so it does not fit either definition. Negative numbers are not prime either, because prime numbers are defined for whole numbers greater than 1.

      Keeping 1 out of the primes is not a quirk. It protects the Fundamental Theorem of Arithmetic, which says that every whole number greater than 1 is either prime or breaks down into prime factors in exactly one way. If 1 counted as prime, 6 could be written as 2 × 3, or 1 × 2 × 3, or 1 × 1 × 2 × 3, and the factorization would no longer be unique. With 1 excluded, every number has exactly one prime factorization, and this checker can show it with confidence.

      Trial division and the Miller-Rabin test

      For numbers up to 100, this checker uses trial division: it tests the number against prime divisors up to its square root. If no divisor up to the square root divides it, the number must be prime, because any factor larger than the square root would have to pair with a factor smaller than it. To test 97, the square root is about 9.85, so only 2, 3, 5, and 7 need trying. None of them divides 97, so 97 is prime. The same test catches 91, which looks prime at a glance but is 7 × 13.

      For larger numbers, trial division alone is too slow, so the checker switches to the Miller-Rabin test with the twelve bases 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, and 37. Those twelve bases are proven to give the exact answer for every number below 318,665,857,834,031,151,167,461, a result due to Sorenson and Webster. That bound is far above the largest number most people ever test, which is why the checker can give a definite answer instead of a probability. The number 2,305,843,009,213,693,951, which is 2 to the power of 61 minus 1, passes all twelve bases and is prime: a Mersenne prime, named after the numbers of the form 2 to a power minus 1.

      One family of numbers needs a warning. Carmichael numbers are composite numbers that fool the simpler Fermat test into calling them prime. The smallest is 561, which equals 3 × 11 × 17, and the next are 1105 and 1729. Trial division catches them at once, and the Miller-Rabin test with twelve bases catches them too, so this checker never mistakes one for a prime.

      The Sieve of Eratosthenes

      To list primes in a range, the checker runs the Sieve of Eratosthenes, a method more than 2,000 years old. Write out the numbers, then cross out the multiples of each prime, starting from the square of that prime, and stop when the square of the prime passes the top of the range. The numbers left standing are prime. Starting at the square is the clever part: every smaller multiple of the prime has already been crossed out by a smaller prime.

      The checker runs a segmented version of the sieve, which works through the range in slices instead of writing out every number from 2. That is what makes it possible to search near one trillion, for example finding the four primes between 999,999,999,900 and 999,999,999,999, without listing a trillion numbers first.

      Prime factorization

      Prime factorization breaks a number into the primes that multiply to give it. The standard method is the ladder: divide by the smallest prime that fits, write down the quotient, and repeat until the quotient is 1, or until the quotient itself is prime. For 360, the chain is 360 ÷ 2 = 180, 180 ÷ 2 = 90, 90 ÷ 2 = 45, 45 ÷ 3 = 15, 15 ÷ 3 = 5, and 5 is prime, so 360 = 2³ × 3² × 5. The exponents count how many times each prime appears.

      Factorization is the key to several other calculations. The greatest common divisor of two numbers comes from the prime factors they share, which is what our GCF Calculator finds. The least common multiple comes from combining their prime factors, which is what our LCM Calculator finds: 12 is 2² × 3, 18 is 2 × 3², and their least common multiple is 36. Prime factors also simplify fractions, because a factor shared by the top and bottom of a fraction can be cancelled, as our Fraction Calculator shows. And if you need square roots or powers while working with primes, our Scientific Calculator handles them.

      What your result means

      In check mode, the verdict is one of three things. "Prime" means the number has exactly two factors, 1 and itself. "Composite" means it has more factors, and the result names the smallest one, with the paired factor beside it. "Neither prime nor composite" appears for 1, 0, and negative numbers, with the reason spelled out in the steps. The method line tells you how the verdict was reached: by definition for 2, by trial division up to 100, and by the Miller-Rabin test above that.

      For very large composite numbers, there is one honest limit. Above 9,007,199,254,740,991, the checker searches for the smallest factor up to 100,000,000. If the smallest factor is larger than that, the Miller-Rabin test still proves the number composite, but the checker says plainly that it did not pin the factor down, instead of guessing. In factor mode, a prime input returns itself as its only prime factor, and 1 returns no factors at all, because 1 has no prime factorization. In range mode, the result gives the count first, then the list; when the list is long, the summary names the smallest and largest primes found.

      Prime numbers in real life

      The best-known use of prime numbers is in cryptography, the mathematics that keeps internet data secure. The RSA system, one of the most widely used public-key methods, relies on the difficulty of factoring the product of two large prime numbers. Multiplying two large primes together is easy, but working out which primes were multiplied, starting from the product alone, is enormously hard. That gap between easy multiplication and hard factorization is what lets two strangers exchange secret messages over an open network. Primality testing is part of the same story: before two large primes can be multiplied, each one has to be proven prime, and the Miller-Rabin test is one of the standard tools for doing that.

      Common prime number mistakes

      The most common mistake is calling 1 a prime number. It is not, and it is not composite either. It sits in a class of its own, and treating it as prime breaks the uniqueness of prime factorization. The second mistake is the mirror image: thinking 2 is not prime because it is even. The number 2 is prime, and it is the only even prime. "Odd" and "prime" are not the same thing.

      The third mistake is trusting a number that merely looks prime. The number 91 is the classic trap: it is 7 × 13. The numbers 51 and 57 fall the same way, as 3 × 17 and 3 × 19. Any number ending in 5 and larger than 5 is divisible by 5, and any number whose digits add up to a multiple of 3 is divisible by 3, which catches 51 and 57 at a glance.

      The fourth mistake is stopping the divisibility test too early. To prove a number prime by trial division, you must test every prime up to its square root, not just the first few. The number 143 is 11 × 13, and its square root is about 11.96, so a test that stopped at 7 would wrongly call it prime. The checker never stops early: it tests up to the square root, or runs the full Miller-Rabin test with all twelve bases.

      Frequently asked questions

      Is 1 a prime number?

      No. A prime number must have exactly two factors, 1 and itself, and 1 has only one factor, itself. The number 1 is neither prime nor composite. Keeping it out of the primes protects the Fundamental Theorem of Arithmetic, which says every whole number greater than 1 has exactly one prime factorization.

      Is 2 a prime number?

      Yes. The number 2 has exactly two factors, 1 and 2, so it is prime. It is the only even prime number, because every other even number is divisible by 2 as well as by 1 and itself. Prime numbers are not the same as odd numbers: 9, 15, 21, and 25 are all odd and all composite.

      How do you check if a large number is prime?

      Use the Miller-Rabin test with the twelve bases 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, and 37. Those bases are proven to give the exact answer for every number below 318,665,857,834,031,151,167,461, so the verdict is definite, not a probability. This checker runs that test for every number above 100, after a quick trial division by the primes up to 97.

      What is the prime factorization of 360?

      The prime factorization of 360 is 2³ × 3² × 5. Divide by the smallest prime that fits, and repeat: 360 ÷ 2 = 180, 180 ÷ 2 = 90, 90 ÷ 2 = 45, 45 ÷ 3 = 15, 15 ÷ 3 = 5, and 5 is prime. Multiply back to check: 2 × 2 × 2 × 3 × 3 × 5 = 360.

      How many prime numbers are there between 1 and 100?

      There are 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. The count grows more slowly as numbers get larger: there are 168 primes below 1,000 and 1,229 below 10,000.

      What is the largest prime number this checker can test?

      This checker tests whole numbers below 318,665,857,834,031,151,167,461, the bound below which the twelve Miller-Rabin bases are proven exact. Numbers are typed as digits and read exactly, with no rounding, so a 20-digit number is tested precisely. For example, 2,305,843,009,213,693,951, which is 2 to the power of 61 minus 1, is prime.

      Why does the checker sometimes not show the smallest factor?

      For composite numbers above 9,007,199,254,740,991, the checker searches for the smallest factor up to 100,000,000. If the smallest factor is larger than that, the Miller-Rabin test still proves the number composite, but finding the factor would take too long, so the checker says so honestly instead of guessing. Below that size, the checker always finds and shows the smallest factor.

      What is a Carmichael number?

      A Carmichael number is a composite number that fools the simpler Fermat primality test into calling it prime. The smallest is 561, which equals 3 × 11 × 17, and the next are 1105 and 1729. Trial division catches them at once, and the Miller-Rabin test with twelve bases catches them too, so this checker always reports them as composite.

      Sources

      • Wikipedia, Miller–Rabin primality test — if n is below 318,665,857,834,031,151,167,461, it is enough to test the bases 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, and 37 (Sorenson and Webster); the same twelve bases suffice below 2 to the power of 64 (Feitsma and Galway). Accessed 20 November 2026.
      • Khan Academy, Prime and composite numbers intro — a prime number has exactly two factors; 7 is prime; 16 is composite, with factors 1, 2, 4, 8, and 16; 1 is neither prime nor composite; 2 is the only even prime; 0 is neither. Accessed 20 November 2026.
      • Math is Fun, Prime Numbers and Composite Numbers — a prime number has exactly two factors; 1 is not prime and not composite; 12 equals 2 × 2 × 3, which is 2² × 3; prime numbers help keep internet data secure using cryptography, because multiplying primes together is much easier than figuring out which primes were multiplied. Accessed 20 November 2026.
      • Math is Fun, Prime Properties — beyond 3, primes sit next to a multiple of 6. Accessed 20 November 2026.
      • Math is Fun, Fundamental Theorem of Arithmetic — every integer greater than 1 is prime or a unique product of primes. Accessed 20 November 2026.
      • OpenStax, Prealgebra 2e, Prime Factorization and the Least Common Multiple — prime factorization by the factor tree and ladder methods; 36 equals 2 × 2 × 3 × 3; the least common multiple from prime factors, with 12 as 2 × 2 × 3 and 18 as 2 × 3 × 3 giving 36. Accessed 20 November 2026.
      • Brigham Young University, Math 495R, Prime Sieves — the Sieve of Eratosthenes crosses out multiples of each prime starting from its square and stops when the square of the prime exceeds the top of the range; the primes to 100. Accessed 20 November 2026.
      • Wikipedia, RSA cryptosystem — the security of RSA is related to the difficulty of factoring the product of two large prime numbers. Accessed 20 November 2026.