def composite_value(n, min_p=0):
    for p in primesiter(n):
        if p < min_p:
            continue
yield p, [p]
for t, r in composite_value(n // p, min_p=p):
    yield t * p, [p] + r
Efficiently generate all composite numbers less than N (with their factorizations)