# Revision history [back]

The factorization of a polynomial is an object with its methods:

sage: R.<x> = ZZ[]
sage: f = (x-1)^3*(x+2) ; f
x^4 - x^3 - 3*x^2 + 5*x - 2

sage: F = f.factor() ; F
(x + 2) * (x - 1)^3
sage: type(F)
<class 'sage.structure.factorization.Factorization'>


So, this objects has its methods, which you can call more or less directely:

sage: F.__len__()
2
sage: len(F)
2
sage: list(F)
[(x + 2, 1), (x - 1, 3)]
sage: dict(F)
{x - 1: 3, x + 2: 1}


You question is a bit ambiguous, since it is not clear whether you want the number of factors counting with or without cultiplicity.

Without multiplicity, you canjust call the length:

sage: len(F)
2
sage: len(dict(F))
2


With multiplicity, you have to sum the multipicities of all factors:

sage: dict(F).values()
[1, 3]
sage: sum(dict(F).values())
4