factors

mathtools.factors(n)

Gets prime factors less than or equal to n .

>>> mathtools.factors(84)
[2, 2, 3, 7]
>>> for n in range(10, 20):
...   print(n, mathtools.factors(n))
...
10 [2, 5]
11 [11]
12 [2, 2, 3]
13 [13]
14 [2, 7]
15 [3, 5]
16 [2, 2, 2, 2]
17 [17]
18 [2, 3, 3]
19 [19]

n must be a positive integer.

Returns factors in increasing order.

Returns list of positive integers.