Help:=proc(): print(`fSni(S,n,i), fSTnx(S,T,n,x) `): print(` fSTn(S,T,n) , SeqSTN(S,T,N) `): end: #inputs a set of integers S, and another set of integers #T and an integer n, and outputs the number of sequences #of length n, whose entries belong to S, whose sum is i fSni:=proc(S,n,i) local x, P,s: P:=add(x^s,s in S): coeff(P^n,x,i): end: #KickOut(f,x,T): Inputs a polynomial in a variable x, and #a set of integers T, and substracts all the terms involving #x^t, t in T KickOut:=proc(f,x,T) local t: f- add( coeff(f,x,t)*x^t, t in T): end: #inputs a set of integers S, and another set of integers #T and an integer n, and outputs the generating #polynomial whose coeff. of x^i is the number of sequences #of length n, whose entries belong to S, and NONE of #whose partial sums (except possibly the 0^th) ever belong to T #and whose sum is i fSTnx:=proc(S,T,n,x) local f,P,s: if n=0 then RETURN(1): fi: f:=fSTnx(S,T,n-1,x): P:=add(x^s,s in S): KickOut(f*P,x,T): end: fSTn:=proc(S,T,n) local x: subs(x=1,fSTnx(S,T,n,x)): end: SeqSTN:=proc(S,T,N) local n: [seq(fSTn(S,T,n),n=1..N)]: end: