Calcorithmevery number has an answer
πŸ”
All tools β†’
← Math

Prime Number Checker

Check if a number is prime and find its prime factorization.

Enter a numberi
97
is βœ“ PRIME

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 PRIME

The 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

Cryptography
RSA encryption β€” which secures every HTTPS website β€” relies on the fact that multiplying two large primes is fast, but factoring the product back into primes is computationally infeasible.
Hash functions
Many hash algorithms and hash table implementations use prime numbers as moduli to reduce collisions and distribute data more uniformly.
Number theory
The Riemann Hypothesis β€” one of the greatest unsolved problems in mathematics β€” is fundamentally about the distribution of prime numbers.
Random number generation
Prime moduli are used in linear congruential generators and other pseudo-random number algorithms to maximise the period before the sequence repeats.

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.
iFormula / How it works

Trial division up to √n. Prime factorization by repeated division.