refactoring print polynomial