factors

mathtools.factors(n)

Prime factors less than or equal to positive integer n in increasing order.

Example 1. Factors 84:

>>> mathtools.factors(84)
[2, 2, 3, 7]

Example 2. Factors the number 10 through 19, inclusive:

>>> 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]

Raises type error on noninteger n.

Raises value error on nonpositive n.

Returns list of one or more positive integers.