# [seqfan] Re: n-multisets of integers in (-n..n} adding to n

Robert Gerbicz robert.gerbicz at gmail.com
Thu Apr 12 21:55:15 CEST 2012

```2012. április 12. 18:06 Maximilian Hasler írta, <maximilian.hasler at gmail.com
>:

> On Thu, Apr 12, 2012 at 4:03 AM, David Scambler wrote:
> > Count all n-multisets of integers in {-n, ..., n} such that the members
> sum to n.
>
> This is the same than n-multisets of integers in [0..2n] such that the
> members sum to n(n+1).
>
> So it might be interesting to have the more general function
>
> f( n,m,k ) = # of n-multisets in [0..m] whose elements sum up to k.
>
> This cannot obviously be coded as one simple table
> (although for given n and m it will be zero for large enough k (> n*m)
> which nevertheless would allow to pack all in one table or sequence)
>
> One could make one table f(n,m,k) for each n > 2
>
> or alternatively / additionnally only consider m = a*n
> and make a table for
>
> a=1 <=> m=n (already there ?)
> a=2 <=> m=2n (yours, the above)
> a=3 <=> m=3n, etc.
>
>
> Regards,
>
> Maximilian
>
> _______________________________________________
>
> Seqfan Mailing list - http://list.seqfan.eu/
>

A tricky way:
f(n,m,k)=polcoeff(prod(i=0,m,sum(j=0,n,x^(j*i*((m+1)*n+1)+j))),k*((m+1)*n+1)+n)

```