Question: Recursive function definition does not work with sum

Hi! Normally recursively defined functions work well, but if I use a sum inside, this happens:

> y:=n->sum(y(k),k=0..n-1);

                                   n - 1
                     y := n ->   )   y(k)
                                   k = 0

> y(0):=a;

                              y(0) := a

> y(4);
Error, (in y) too many levels of recursion


when it should be 6a.

What can I do? (This is just an example, I don't want an explicit solution to this particular problem)

Please Wait...