Prove that the number of ways of writing n as a sum of consecutive integers is d(m) where m is the largest odd number dividing n.

OK so here is a selection of my attempts to date!

If x is the first number in the sum and there are r+1 terms we have:

$\displaystyle n = x + (x+1) + (x+2) + ... + (x+r) = (r+1)*x + 1 + 2 + ... + r = (r+1)*x + \frac{r(r+1)}{2}$

So we must find the number of integer solutions to:

$\displaystyle n = (r+1)*x + \frac{r(r+1)}{2}$

Not sure how to proceed from here so I tried starting from the answer. If

$\displaystyle n=2^{a_1}3^{a_2}5^{a_3}...P_s^{a_s}$

then

$\displaystyle m=3^{a_2}5^{a_3}...P_s^{a_s}$

and

$\displaystyle d(m)=(1+a_2)(1+a_3)....(1+a_s)$

Help please!