Simple Recursion Definition

48 Views Asked by At

I have the following equation which is what f is equals to, and am told to write the recursive definition for it. I know that the base case is simply: when n = 0, we can say that the function f = 0^2+2(0)+1 = 1

However, for the recursive definition I am very stuck, as I do not know how to define it. I believe the mathematical formula for this is $\frac{n(n+1)(2n+1)}{6}$, yet I am unclear how to translate this. $$\sum_{i=1}^n i^2+2i+1$$