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:

So we must find the number of integer solutions to:

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

then

and

Help please!