python library to generate all factors of an integer?

Viewed 27

I tried sympy.factorint() but it returns a dictionary of prime factors with count. I need all factors in a list in ascending order.

import sympy
sympy.factorint(567)

output

{3: 4, 7: 1}

I am looking for output like this

[1, 3, 7, 9, 21, 27, 63, 81, 189, 567]
1 Answers

Found solution I should use sympy.divisors() instead

import sympy
sympy.divisors(n)
Related