__str__ method for Factor class