Nth term of a quadratic sequence