Let's say I have polynomial $P(n,i)=(i+1)(n+1)^2$. I want to sum $k$ $P$'s, but with a twist: $n$ for any $P$ is based upon the $P$'s before it. So, in code, what I want is this:
def P(n,i):
return i*(n**2)
V=0
S=0
for i in range(k):
S+=P(V,i)
V+=P(V,i)
print(S)
However, of course, I want to formulate this in a more mathematical notation. So, how can I keep a "local variable" $V$ in a sum and modify it across each term?