Prime Number Checker
Check if a number is prime and find its prime factorization.
What is a prime number?
A prime number is a natural number greater than 1 that has exactly two distinct divisors: 1 and itself. The number 7 is prime because nothing divides it evenly except 1 and 7. The number 6 is not prime because it is divisible by 1, 2, 3, and 6.
Prime numbers are the βatomsβ of arithmetic β every integer greater than 1 can be expressed as a unique product of primes. This is the Fundamental Theorem of Arithmetic, and it is the reason primes sit at the heart of number theory, cryptography, and computer science.
1 is not a prime number by definition β this exclusion is deliberate. If 1 were considered prime, the uniqueness of prime factorisation would break down (12 = 2 Γ 2 Γ 3, but also 1 Γ 2 Γ 2 Γ 3, and 1 Γ 1 Γ 2 Γ 2 Γ 3β¦).
How to check if a number is prime
The most straightforward method is trial division: test whether any integer from 2 up to the square root of n divides n evenly.
For n = 97:
β97 β 9.85 β test divisors 2, 3, 4, 5, 6, 7, 8, 9
97 Γ· 2 = 48.5 (no)
97 Γ· 3 = 32.3 (no)
97 Γ· 5 = 19.4 (no)
97 Γ· 7 = 13.8 (no)
No divisor found β 97 is PRIMEThe key insight is that you only need to test up to βn. If n has a factor larger than βn, it must also have a corresponding factor smaller than βn β and that smaller one would have been found first.
Primes up to 100
There are 25 prime numbers between 1 and 100. Tap any to check it in the tool:
Prime factorisation
Every composite number (non-prime) can be broken down into a product of prime numbers. This process is called prime factorisation, and the result is unique for every number β there is only one way to write any integer as a product of primes (ignoring order).
360 = 2 Γ 2 Γ 2 Γ 3 Γ 3 Γ 5 = 2Β³ Γ 3Β² Γ 5
2,310 = 2 Γ 3 Γ 5 Γ 7 Γ 11
1,000,000 = 2βΆ Γ 5βΆPrime factorisation is used to find the greatest common divisor (GCD) and least common multiple (LCM) of numbers β important in simplifying fractions, scheduling problems, and coding theory.
Why prime numbers matter
Interesting facts about primes
- There are infinitely many primes. Euclid proved this around 300 BC. Assume a finite list β multiply them all together and add 1. The result is either prime or has a prime factor not on your list. Contradiction.
- 2 is the only even prime. Every other even number is divisible by 2, so it cannot be prime.
- Twin primes. Pairs of primes that differ by 2, like (11, 13), (17, 19), (41, 43). It is conjectured that there are infinitely many twin prime pairs, but this remains unproven.
- The largest known prime (as of 2024) has over 41 million digits. It is a Mersenne prime of the form 2βΏ β 1, found by the GIMPS distributed computing project.
- Prime gaps grow on average, but are irregular. Sometimes large primes appear very close together; other times there are long βdesertsβ with no primes.
Trial division up to βn. Prime factorization by repeated division.