# Partition integer into n parts, with constraint on each part [duplicate]

$x_1,x_2,...,x_n$ are integer numbers in the range [0,B-1]. Count the number of solution for $x_1+x_2+...+x_n=k$.

I know this problem is similar to the one here Number of ways of partitioning a sum into ordered non-negative summands

But now there is constraint on the range of $x_i$. In the problem text it gives a hint to use principle of inclusion and exclusion. Does anyone have a clue?

-

## marked as duplicate by Brian M. Scott, Martin, Amzoti, vonbrand, tomaszMay 17 '13 at 20:49

This question was marked as an exact duplicate of an existing question.

@BrianM.Scott I don't see how the first question you linked is related, but the second is essentially the same, so I'll vote to close. – tomasz May 17 '13 at 20:49
@tomasz: They’re all three essentially the same question: how many solutions in non-negative integers are there to $\sum_{k=1}^mx_k=n$ subject to the constraint that each $x_k\le b$? – Brian M. Scott May 17 '13 at 20:53
@BrianM.Scott: I see now. You're right. :) – tomasz May 17 '13 at 21:45