Prime Number Calculator

Check if a number is prime, find nearest primes, and list all primes up to n with step-by-step solutions.

Enter a Number

Result

Is it Prime?
97
PRIME
Number 97
Check up to floor(sqrt(97)) = 9
Previous Prime 89
Next Prime 101
Prime Position 25th prime

Step-by-Step Divisibility Tests

97 is prime (not divisible by 2, 3, 5, 7)

Primes up to 97:

Understanding Prime Numbers

A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29. The number 2 is the only even prime number; all other even numbers are divisible by 2 and therefore composite.

How to Check if a Number is Prime

To determine if a number n is prime, you only need to check divisibility by all primes up to the square root of n. If n has a factor larger than its square root, the corresponding cofactor must be smaller than the square root, so you would have already found it.

Trial Division

Test divisibility by primes 2, 3, 5, 7, 11, ... up to the square root.

Check d | n for d <= sqrt(n)

Sieve of Eratosthenes

Efficiently find all primes up to a given limit by elimination.

Mark multiples of each prime

Prime Counting Function

pi(n) counts the number of primes less than or equal to n.

pi(n) ~ n / ln(n)

Twin Primes

Pairs of primes that differ by 2, like (11, 13) or (29, 31).

p and p+2 both prime

Important Properties

  • 1 is NOT a prime number (by convention and for mathematical consistency).
  • 2 is the smallest and only even prime number.
  • Every integer greater than 1 is either prime or can be uniquely factored into primes (Fundamental Theorem of Arithmetic).
  • There are infinitely many primes (proven by Euclid around 300 BC).
  • The Prime Number Theorem states that pi(n) is approximately n/ln(n) for large n.
  • All primes greater than 3 are of the form 6k +/- 1.

Applications of Prime Numbers

Prime numbers are the backbone of modern cryptography, particularly in RSA encryption, which relies on the difficulty of factoring large semiprimes (products of two large primes). They also appear in hash functions, random number generators, and error-correcting codes. In pure mathematics, primes are central to number theory, and many unsolved problems (like the Goldbach Conjecture and the Riemann Hypothesis) involve primes.

Famous Unsolved Problems

  • Goldbach's Conjecture: Every even integer greater than 2 can be expressed as the sum of two primes.
  • Twin Prime Conjecture: There are infinitely many pairs of primes that differ by 2.
  • Riemann Hypothesis: The distribution of primes is intimately connected to the zeros of the Riemann zeta function.