Enter a number to find out whether it is prime or composite; a composite number is shown as a product of two factors. Up to one trillion you see the trial division by primes up to โn; bigger numbers (up to 24 digits) use the MillerโRabin test.
๐ Is it a prime number?
Find the primes in a range
The end of the range can be up to one trillion, and one search can cover up to 100,000 numbers.
๐งญ How to use it
- Type a whole number and press Check. You see whether it is prime or composite and why.
- For a composite number you get a factor pair and its prime factorization; for any number up to 20 digits, the previous and next primes.
- To list primes, enter a range such as 1 to 100 under Find the primes in a range.
๐งน Sieve of Eratosthenes: primes from 1 to 100
Cross out 1, then keep 2, 3, 5 and 7 and cross out their multiples in turn. The next prime, 11, has 11 ร 11 = 121, which is more than 100, so nothing else needs crossing out. Every number left is prime.
The 25 prime numbers up to 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, 97
๐ How to tell if a number is prime
- A prime number is a whole number greater than 1 whose only factors are 1 and itself; a composite number has three or more factors. 1 is neither prime nor composite.
- 2 is the smallest prime and the only even prime. Every even number greater than 2 divides by 2, so it is composite.
- If n is composite, then n = a ร b where at least one of a and b is no more than โn. So it is enough to try dividing by the primes up to โn.
Example โ 91: โ91 โ 9.5, so try 2, 3, 5 and 7. 91 รท 7 = 13, so 91 = 7 ร 13 is composite.
Example โ 97: โ97 โ 9.8, so try 2, 3, 5 and 7. None divides it evenly, so 97 is prime.
Quick divisibility rules
- Divisible by 2: the last digit is 0, 2, 4, 6 or 8.
- Divisible by 3: the sum of the digits is a multiple of 3 (2 + 0 + 2 + 7 = 11, so 2027 is not).
- Divisible by 5: the last digit is 0 or 5.
- Divisible by 11: the alternating sum of the digits is 0 or a multiple of 11 (1001 โ 1 โ 0 + 0 โ 1 = 0, so it is).
For numbers above 1012, trying one prime at a time would take too long, so the checker uses the MillerโRabin test with the first 13 primes (2 to 41) as bases. With these bases the test is known never to give a wrong answer for numbers below 3.3 ร 1024.
โ Frequently asked questions
What is a prime number?
A prime number is a whole number greater than 1 whose only factors are 1 and itself, such as 2, 3, 5, 7, 11 and 13. A whole number greater than 1 that is not prime is called a composite number.
Is 1 a prime number?
No. 1 has only one factor, so it is neither prime nor composite. Leaving 1 out of the primes is what makes every whole numberโs prime factorization unique.
How do you check whether a number is prime?
Try dividing it by the primes up to its square root. If any of them divides it evenly the number is composite; if none does, it is prime. 91 divides by 7, so it is composite; 97 does not divide by 2, 3, 5 or 7, so it is prime.
How many prime numbers are there up 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 and 97. There are 168 primes up to 1000.
Can it check very large numbers?
Yes, up to 24 digits. Up to one trillion (10 to the 12th power) it divides by the primes up to the square root; above that it uses the MillerโRabin test with the 13 primes from 2 to 41 as bases, which is known to be correct for every number below 3.3 ร 10 to the 24th power.
๐ More math calculators
Practice more: Math Worksheet Generator ยท Multiplication Chart ยท Percentage Calculator ยท Unit Converter
5 uses today ยท Everything is calculated in your browser โ the numbers you enter are never sent to a server.