Factoring quadratics and cubics