← Back to challenges

Semiprimes

PythonHardmathvalidationnumbers

Instructions

A semiprime is a composite number that is the product of two primes. Apart from these two primes, its only other proper (non-self) divisor is 1.

The two prime factors of a semiprime can be the same number (e.g. the semiprime 49 is the product of 7x7). A semiprime that has two distinct prime factors is called a squarefree semiprime.

Create a function that takes a number and returns "Squarefree Semiprime", "Semiprime", or "Neither".

Examples

semiprime(49) ➞ "Semiprime"

semiprime(15) ➞ "Squarefree Semiprime"

semiprime(97) ➞ "Neither"

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.