An example, because I don't want this thread to die today.
If
# ways
= COMB(oc-1,n-1) + SUM(i=1,n-1) {(-1)^i * IF[oc<(i*s+n),0,COMB(n,i)*COMB(oc-i*s-1,n-1)]}
Then
for 4d6,
# ways of getting a 17 =
= COMB(16,3) - COMB(4,1)*COMB(10,3) + COMB(4,2)*COMB(4,3) - 0
= 16!/(13!*3!) -...