1def divisorGen(n):
2 factors = list(factorGenerator(n))
3 nfactors = len(factors)
4 f = [0] * nfactors
5 while True:
6 yield reduce(lambda x, y: x*y, [factors[x][0]**f[x] for x in range(nfactors)], 1)
7 i = 0
8 while True:
9 f[i] += 1
10 if f[i] <= factors[i][1]:
11 break
12 f[i] = 0
13 i += 1
14 if i >= nfactors:
15 return
16
17# Excerpt from stackoverflow (: