1 | initial version |
You can easily do it recursively
def elementary_divisors(n, m=1):
if n == 1:
yield []
return
for d in n.divisors():
if d == 1 or d % m:
continue
for ll in elementary_divisors(n // d, d):
yield [d] + ll
Then
sage: list(elementary_divisors(48))
[[2, 2, 2, 6], [2, 2, 12], [2, 24], [4, 12], [48]]