TITLE: Detecting almost-primes quickly
QUESTION [12 upvotes]: There are many fast algorithms (deterministic and probabilistic) for detecting primality. Are there any fast algorithms (probabilistic ones allowed) known for detecting whether a number is the product of at most two primes?
In this context, can anybody think of a property fulfilled by all or most products of two primes, but by few other numbers? (You can't explicitly use divisor sums or the Moebius function, obviously, as then the game becomes (a) trivial (b) of doubtful computational utility.)

REPLY [2 votes]: There is a survey of open problems related to factoring algorithms, Open problems in number theoretic complexity, II, by Adleman and McCurley.  It lists so many questions related to distinguishing almost primes from other composite numbers that it seems safe to infer that it is an open problem to do it quickly, and that you would either use a factoring algorithm or a related method.  For instance, computing the Mobius function as you say is a known open problem, and detecting an almost prime can be viewed as a special case of computing the Mobius function.  Because, of course, it is easy to distinguish a prime from an almost prime.
As for relevant properties, the most important relevant property of a prime $p$ is that its multiplicative group $(\mathbb{Z}/p)^\times$ is cyclic of order $p-1$.  The Miller-Rabin primality test is based on that fact.  Now, if $n = pq$ is an odd almost prime, then the multiplicative group $(\mathbb{Z}/n)^\times$ is a product of two cyclic groups. Conversely, if $(\mathbb{Z}/n)^\times$ is a product of two cyclic groups and $n$ is odd, then $n$ is a product of two prime powers.  But, there is too little control over the cardinality of this group.  In the almost prime case, it has $(p-1)(q-1)$ elements.  Even if you found the 2-torsion elements, in other words all solutions to $x^2 \equiv 1 \bmod n$, you would be able to factor $n$.
The set of almost prime numbers is an important statistical ersatz for the set of prime numbers in analytic number theory.  However, in computational number theory, no particular reason leaps out that identifying almost primes is easier than other factoring-related questions that are accepted as hard.