Having trouble with a double summation function that calls itself recursively.
S2 := (p, k, n)-> piecewise(0 <= n and n < k, 1, n < 0, 0, sum(sum(p^y*(1-p)^(m-y)*S2(p, k, n-m), m = y+1 .. y+k-1), y = 1 .. n-k+1));
When evaluated with S2(p,2,-1) and S2(p,2,1) it works correctly (first two conditions are working)
However, when I try evaluate S2(p,2,2) Maple appears to run unbounded(?) and chokes. In fact, doing...