Prime Number Checker
: Check whether a number is prime, up to 1,000 digits, with its smallest factor, prime factorization, next and previous prime; list the primes up to N or between two numbersPrime Number Checker
A prime number checker for whole numbers up to 1,000 digits: type a number and it says whether it is prime, and if not, its smallest factor and its prime factorization, with the next and previous prime. It is also a prime factorization calculator with every divisor, and it lists the primes up to any number or between two numbers. With the box empty it shows the list of prime numbers under 1,000. It runs in your browser.
How to check if a number is prime
- Type a number in
Numbers, one per line, or paste several, one per line.1,000,003,1 000 003and1_000_003are all read as one number, and powers such as2^61-1are worked out. TheExamplesmenu has a few to try. - Leave the mode on
Is it prime?to get the answer, the smallest factor, the factorization, the previous and next prime and, up to 10,000,000, the number's position among the primes. Several lines give a table: number, prime or not, smallest factor and factorization. - Choose
Prime factorizationfor the prime factors, the number of divisors, their sum, the list of divisors and each division step. - Choose
List primesand type1000for the primes up to 1,000, or100-200(also100 to 200,between 100 and 200) for the primes between.List separatorsets commas or one prime per line for Copy list; Download has both. - A long job (a sieve to 100,000,000, a hard factorization, a test of a 1,000-digit number) shows its progress and a Cancel button. Cancel on a factorization keeps the factors found so far.
Example
Three numbers, one per line, in Is it prime?: a prime, a composite with its factors, and 561, the smallest Carmichael number, which fools the simple Fermat test but not this one.
97
91
561Yes: 97 is a prime number
No: 91 is a composite number: 91 = 7 × 13
No: 561 is a composite number: 561 = 3 × 11 × 17Details
- What a prime number is. A prime is a whole number greater than 1 whose only divisors are 1 and itself. Every other whole number above 1 is composite: a product of primes in exactly one way, up to order, such as 360 = 2³ × 3² × 5. 0 and 1 are neither prime nor composite, and 2 is the only even prime.
- How the answer is proven. Below 3,317,044,064,679,887,385,961,981 (about 3.3 × 10²⁴) the checker runs the Miller–Rabin test with the 13 prime bases 2 to 41, which is known to give the right answer for every number in that range, so "prime" there is a proof. It catches the numbers that fool weaker tests: Carmichael numbers such as 561 and 41,041, and strong pseudoprimes such as 3,825,123,056,546,413,051 = 149491 × 747451 × 34233211, which passes Miller–Rabin for every prime base up to 31. A Mersenne number 2^p − 1 is proven by the Lucas–Lehmer test, so 2^127 − 1 is shown as prime.
- Probable primes. Above 3.3 × 10²⁴ there is no fast proof. The checker then runs Miller–Rabin with the first 20 prime bases and a strong Lucas test with Selfridge's parameters, which together make the Baillie–PSW test. A number that passes is shown as a probable prime (no counterexample is known), never as prime. A number that fails is certainly composite.
- The next and previous prime and the position. For 97 the previous prime is 89 and the next is 101, and 97 is the 25th prime. The position comes from a sieve count of the primes up to 10,000,000, so it is given for numbers up to there; for a composite number it says how many primes are below it. For big numbers the next prime is found by sieving a window of candidates with the primes below 65,536 and testing the ones left.
- Prime factorization. Trial division by the primes below 65,536 finds every small factor, smallest first; Pollard's rho method (Brent's version) splits what is left, and each part is tested for primality. 2^64 + 1 = 18,446,744,073,709,551,617 splits into 274177 × 67280421310721. The result gives the number of divisors (for 360, 24: the powers plus one, multiplied), their sum and, when there are at most 10,000, the list of divisors. In Is it prime?, the factor search stops after 2 seconds and says the number is still certainly composite; Prime factorization keeps going until you cancel.
- Lists of prime numbers. List primes runs a segmented sieve of Eratosthenes over the odd numbers in steps, so the page stays usable. It gives the count, the number of twin prime pairs (primes 2 apart), the smallest and largest prime, a searchable table with each prime's position, and the list to copy or download. There are 25 primes up to 100, 168 up to 1,000 with 35 twin pairs, 21 between 100 and 200, and 78,498 up to 1,000,000. There is no list of all prime numbers: there are infinitely many, as Euclid proved.
- A list of prime and composite numbers. Paste numbers one per line in Is it prime? and the table labels each one prime, composite or neither, with its smallest factor and factorization. Blank lines are skipped, and a line that is not a whole number (
7.5,abc) says why. Negative numbers are answered plainly: primes are greater than 1, so no negative number is prime.
Limits
- Whole numbers up to 1,000 digits. Decimals, fractions and e-notation are not read as numbers; a decimal is answered as not a whole number.
- Factoring time grows with the square root of the smallest prime factor, so a product of two primes of 20 digits or more may not split in any reasonable time. The answer to Is it prime? does not depend on it: compositeness is proven by Miller–Rabin without a factor.
- No primality certificate. Above 3.3 × 10²⁴, numbers other than Mersenne numbers get the probable-prime answer.
- A list keeps up to 50,000,000 primes, as numbers, text and a table at once in the page's memory; a larger range is still counted, with its twin primes, but the primes are not listed. The table holds the first 1,000,000 primes; the text and Download hold all of them.
FAQ
What is a prime number?
A whole number greater than 1 that has exactly two divisors, 1 and itself, such as 2, 3, 5, 7, 11 and 13. A whole number above 1 with more divisors is composite: 91 is composite because 91 = 7 × 13.
Is 1 a prime number?
No. A prime has exactly two divisors and 1 has only one, itself. 1 is neither prime nor composite, and so is 0. Type 1 to see the answer with the next prime, 2.
What are the prime numbers from 1 to 100?
There are 25: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97. With the box empty the page shows this list of prime numbers to 100 and the table of the primes under 1,000; List primes gives the list to 1,000, to 1,000,000 or to any number.
How does the prime factorization calculator work?
It divides by the primes below 65,536, smallest first, then uses Pollard's rho method on the part left and tests each part for primality until every factor is prime. The steps are shown as a list of divisions, such as 360 ÷ 2 = 180.
Why does a big number say probable prime?
Above 3.3 × 10²⁴ no fast test proves a number prime. The number passed the Baillie–PSW test, which no known composite number passes, but which has not been proven for every number. A Mersenne number is the exception: the Lucas–Lehmer test proves it.
Runs entirely in your browser. Nothing is uploaded.