Semiprime Calculator
Check whether an integer is the product of exactly two primes, counted with multiplicity.
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
- Enter a whole number n from 2 to 1,000,000.
- Read the classification in the main result box.
- Check the factorization shown beside it.
- Count the prime factors yourself to confirm the result.
- The default n = 21 reproduces the worked example.
- Try n = 4 to see a prime square that is also semiprime.
Formula
- 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.
- Factor 21 as 3 x 7.
- Both 3 and 7 are prime.
- Count the prime factors: there are exactly two.
- The tool reports factorization 3 x 7, count 2, and Semiprime.
- For 4 the factorization is 2^2, giving two factors and another semiprime.
- For 12 the factorization 2^2 x 3 gives three factors, so it fails.
Reference table
| n | Factorization | Prime count | Semiprime |
|---|---|---|---|
| 4 | 2^2 | 2 | Yes |
| 6 | 2 x 3 | 2 | Yes |
| 12 | 2^2 x 3 | 3 | No |
| 21 | 3 x 7 | 2 | Yes |
| 25 | 5^2 | 2 | Yes |
| 30 | 2 x 3 x 5 | 3 | No |
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.