def _divisors(n):

    factordict = factorint(n)
    ps = sorted(factordict.keys())

    def rec_gen(n=0):
        if n == len(ps):
            yield 1
        else:
            pows = [1]
            for j in range(factordict[ps[n]]):
                pows.append(pows[-1] * ps[n])
            for q in rec_gen(n + 1):
                for p in pows:
                    yield p * q

    for p in rec_gen():
        yield p
Helper function for divisors which generates the divisors.
dataset/ETHPy150Open sympy/sympy/sympy/ntheory/factor_.py/_divisors