How many ways are there to write $n$ as the sum of consecutive positive integers?
Example: $15$ has $3$ consecutive sums:
$1+2+3+4+5=15$
$7+8=15$
$4+5+6=15$
How many ways are there to write $n$ as the sum of consecutive positive integers?
Example: $15$ has $3$ consecutive sums:
$1+2+3+4+5=15$
$7+8=15$
$4+5+6=15$
Write $$\begin{align}n&=a+(a+1)+\cdots (a+k) \\&= (k+1)a + (1+2+\cdots+k) \\&= (k+1)a+\frac{k(k+1)}{2} \\&= \frac{(k+1)(k+2a)}{2}\end{align}$$
So $2n = (k+1)(k+2a)$.
So you want two write $2n$ as the product of an odd and an even number, and the odd number cannot be $1$. The reason they have to be odd and even is that $k+2a-(k+1)=2a-1$, so $k+1$ and $k+2a$ have different "parities" - they can't be both odd or both even.
So $2\cdot 30 = 3\cdot 10,5\cdot 6,15\cdot 2$.
This will always be equal to the number of odd factors of $n$ other than $1$. That's because an odd factor of $2n$ is an odd factor of $n$.
There isn't a good "magic" formula for this, unless you know to the prime factorization of $n$:
$$n= 2^{a_0}p_1^{a_1}\cdot p_k^{a_k}$$
Then the number of odd factors of $n$ other than $1$ is: $(a_1+1)(a_2+1)\cdots(a_k+1)-1$.
This can be seen because an odd factor of $n$ can be any number of the form $p_1^{b_1}\cdots p_k^{b_k}$ where $0\leq b_i\leq a_k$, so each $b_i$ can take any of $a_i+1$ values, but we have to subtract the one case when all the $b_i=0$, which counts the case when the odd number is $1$.
You can get rid of the "minus 1" thing if you count $15=15$ as the sum of one consecutive integer.
(This means that the only $n$ that cannot be written this way are the powers of $2$.)
Let's try an example. Let's take $n=42.$
Then if we factor $2n=84=7\cdot 12$. Then $k+1=7$ and $k+2a=12$, so $k=6,a=3$ and you get $42=3+4+5+6+7+8+9$.
On the other hand, if you take $2n=84=21\cdot 4$, then $k+1=4$ and $k+2a=21$ so $k=3$ and $a=9$ and you get $42=9+10+11+12$.
HINT:
Factorise $n$ and check the factors and use them accordingly.
Say, for a crude example: $n=p_1p_2p_3$
If $p_2p_3$ is odd, then take $p_2p_3$ and $p_1-1$ numbers before and after $p_2p_3$ and you can write $n$ as a sum of these numbers.
Check for better examples or ask me if you need a more detailed explanation.