Mathwords logoMathwords

Semiprime — Definition, Formula & Examples

A semiprime is a natural number formed by multiplying exactly two prime numbers together. The two primes can be the same or different — for example, 15 = 3 × 5 and 9 = 3 × 3 are both semiprimes.

A natural number nn is a semiprime if and only if n=pqn = p \cdot q, where pp and qq are prime numbers (not necessarily distinct). Equivalently, a semiprime is a positive integer whose prime factorization contains exactly two prime factors counted with multiplicity.

Key Formula

n=pqn = p \cdot q
Where:
  • nn = The semiprime
  • pp = A prime number
  • qq = A prime number (may equal p)

How It Works

To check whether a number is a semiprime, find its prime factorization. If the factorization has exactly two prime factors (counting repeats), the number is a semiprime. For instance, 21 = 3 × 7 has two prime factors, so it qualifies. But 30 = 2 × 3 × 5 has three prime factors, so it does not. A number like 4 = 2 × 2 counts as a semiprime because the two factors are both prime, even though they are the same prime.

Worked Example

Problem: Is 51 a semiprime?
Step 1: Test small primes. Is 51 divisible by 2? No (it is odd). By 3?
51÷3=1751 \div 3 = 17
Step 2: Check whether both factors are prime. 3 is prime. 17 is prime.
51=3×1751 = 3 \times 17
Step 3: The prime factorization has exactly two prime factors, so 51 is a semiprime.
Answer: Yes, 51 is a semiprime because 51 = 3 × 17, a product of exactly two primes.

Why It Matters

Semiprimes play a central role in RSA encryption, the security system behind most online transactions. RSA works because multiplying two large primes is easy, but factoring the resulting semiprime back into its two prime components is extremely difficult for computers. Understanding semiprimes also strengthens your factoring skills for algebra and number theory courses.

Common Mistakes

Mistake: Thinking a semiprime must be the product of two different primes.
Correction: The two primes can be equal. Numbers like 4 = 2 × 2, 9 = 3 × 3, and 25 = 5 × 5 are all semiprimes.