We know that the solution of x1 + x2 + x3 .. xk = n, where xi >= 0 is given by nCr(n + k — 1, n). I was trying to solve a problem in which I had the constraints that all the xi were bounded by ai meaning (xi >= 0 and xi <= ai for all i from 1 to k). I know how to solve this problem using hand (by findind the coefficients and all) but how do I write a code for it or is it possible to write a code for it?