mathtools.factors — Abjad v1.1.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Project Abjad »
- Abjad v1.1.1 documentation »
- Abjad API »

# mathtools.factors

`abjad.tools.mathtools.` `factors`(n)

  Return a list of all integer factors of posittive n:

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

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

  Raise `TypeError` on noninteger n:

      abjad> mathtools.factors(7.5)
      TypeError

  Raise `ValueError` on nonpositive integer n:

      abjad> mathtools.factors(-1)
      ValueError

### Navigation

- index
- modules |
- next |
- previous |
- Project Abjad »
- Abjad v1.1.1 documentation »
- Abjad API »