Semiprime Calculator

Check whether an integer is the product of exactly two primes, counted with multiplicity.

Math and PercentUpdated 2026-11-182 min read
Semiprime Calculator
A whole number from 2 to 1,000,000.
Prime factorization
...
Prime factors with multiplicity...
Classification...

What it does

A semiprime is a natural number that is the product of exactly two prime numbers. The two primes may be the same, so the square of a prime is also a semiprime. The sequence begins 4, 6, 9, 10, 14 and 15.

The name biprime is also used. Because the factors may repeat, the count is taken with multiplicity: 4 is 2 times 2 and qualifies, while 12 is 2 times 2 times 3 and does not.

Semiprimes matter in cryptography because multiplying two large primes is easy, while recovering them from the product is believed to be hard. That asymmetry underlies the RSA cryptosystem.

This page factors the input and counts prime factors with multiplicity, then reports the verdict together with the factorization so the decision is easy to verify.

The input limit is one million, which keeps factoring immediate in a browser. All results are exact integers.

How to use

  1. Enter a whole number n from 2 to 1,000,000.
  2. Read the classification in the main result box.
  3. Check the factorization shown beside it.
  4. Count the prime factors yourself to confirm the result.
  5. The default n = 21 reproduces the worked example.
  6. Try n = 4 to see a prime square that is also semiprime.

Formula

n is semiprime when n = p x q for primes p and q, which may be equal
n
The integer being tested.
p, q
The two prime factors, possibly the same.

Counting with multiplicity means that repeated primes each contribute to the total. The number 4 has two prime factors and is semiprime, while 8 has three and is not. Every semiprime is composite.

Worked example

Example: n = 21

The page opens with n = 21.

  1. Factor 21 as 3 x 7.
  2. Both 3 and 7 are prime.
  3. Count the prime factors: there are exactly two.
  4. The tool reports factorization 3 x 7, count 2, and Semiprime.
  5. For 4 the factorization is 2^2, giving two factors and another semiprime.
  6. For 12 the factorization 2^2 x 3 gives three factors, so it fails.

Reference table

Semiprimes and nearby numbers
nFactorizationPrime countSemiprime
42^22Yes
62 x 32Yes
122^2 x 33No
213 x 72Yes
255^22Yes
302 x 3 x 53No

Limits

  • Inputs above 1,000,000 are rejected to keep factoring quick.
  • Only positive integers greater than one are accepted.
  • The count includes repeated primes.
  • The tool gives a verdict and factorization, not a list of semiprimes.

Common mistakes

  • Counting distinct primes instead of prime factors with multiplicity.
  • Excluding prime squares, which are semiprimes.
  • Including numbers with three prime factors.
  • Treating primes themselves as semiprimes.
  • Confusing this with sphenic numbers, which need three distinct primes.

Try it yourself

Quick checks. Answers sit tucked under each question.

Is 21 semiprime?

Yes, because 21 = 3 x 7.

Is 4 semiprime?

Yes, because 4 = 2 x 2, counting the repeated prime.

Is 12 semiprime?

No, because 12 = 2 x 2 x 3 has three prime factors.

Questions

What is another name for semiprime?

Biprime is the alternative name.

Is a prime square semiprime?

Yes, since the two prime factors may be equal.

Why are semiprimes important?

Their factorization difficulty underlies RSA cryptography.

Are all semiprimes composite?

Yes, by definition.

Are results exact?

Yes, factorization uses integers only.

What input range is accepted?

Whole numbers from 2 through 1,000,000.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.