def _compound_factors(prime_factors):
    """Return a set of all compound factors, given the list of prime factors."""
    compound = set()

    for position, factor in enumerate(prime_factors):
        compound.add(factor)
        remaining = _compound_factors(prime_factors[position+1:])
        for value in remaining:
            compound.add(factor * value)
            compound.add(value)

    return compound