Skip to content
uencoder

Prime Number

A prime number is a natural number greater than 1 divisible only by 1 and itself; it is the building block of number theory, and every integer factors uniquely into primes.

Purpose

To serve as the building blocks of integers, the basis of number theory and cryptography (RSA).

Mechanism

A natural number greater than 1 whose only divisors are 1 and itself. Fundamental theorem of arithmetic: every integer factors uniquely into primes. Primality tests: trial division, Miller-Rabin (probabilistic), AKS (deterministic but slow). There are infinitely many primes (Euclid's proof).

Use cases

  • RSA key generation
  • Diffie-Hellman parameters
  • Prime hash table capacities
  • Number theory research

Examples

  • Input
    The first 10 primes
    Output
    2,3,5,7,11,13,17,19,23,29

    2 is the only even prime

Common errors

Using small primes for RSA moduli
Use large primes (≥1024 bits)

Related terms

Related tools

References