In how many ways can I decompose $n \equiv \pm k \mod{m}$ in a sum of numbers also congruent to $\pm k \mod m$?

49 Views Asked by At

I'm trying to quantify the solutions for the following problem: Given a large $n$ and a small number $m$ such that $n \equiv \pm k \mod{m}$, what is the number of ways I can decompose $n$ on a sum of numbers $n = \sum_{k=1}^N i_k$, such that $i_k \equiv \pm k \mod{m}$?

For instance, if $n=25$, $k=1$ and $m=6$, the numbers between $1$ and $25$ which are $\pm 1 \mod{6}$ are $1,5,7,11,13,17,19,25$ Since $25$ is odd the decomposition must have either 1, 3 or 5 $i_k$s.

For 1 $i_k$ we have $25 = 25$

for 3 $i_k$s we can write $25 = 5+7+13 = 1+5+19 = 7+7+11 = 1+7+17 = 1+11+13$

for 5 $i_k$s we can have $25 = 5+5+5+5+5 = 1+1+1+5+17 = 1+1+1+9+13, \dots$ well I'm not going to display all the variants, you get the idea...

Anyway, for such small $n$ we see there are a lot of possibilities, I am trying to count the number of possibilities but having trouble... Is there an easy way of counting this for general $n,m,k$? Or did someone already study this and have a paper/book/anything on that topic? If so where can I find such material?