Consider
$$\quad N=x+(x+1)+(x+2)+\cdots +(x+n)\\
\implies N=\frac{(n^2 + 2 n x + n + 2 x)}{2}
= \frac{(2x+n)(n+1)}{2}\\
$$
N is the sum of consecutive numbers if and only if $N$ is factorable as
$\space 2N=(2x+n)(n+1).$
For example
$$N=7 \rightarrow
14=\big(2(x)+n\big)\big(n+1\big)=\big(2(3)+1\big)\big(1+1\big),
\quad 7=3+4$$
Now we solve for $x$ and, try values of $n$ where
$\quad\sum_{1}^{n} k<N\quad $ and the highest integer solution where
$\quad (1+2+3+\cdots+n)<N\quad$ indicates $n$ as the maximum possible number of consecutive integers sums equal to $N$.
$$N=\frac{(n^2 + 2 n x + n + 2 x)}{2}
=\frac{2(n+1)x+n(n+1)}{2}
\implies x=\frac{2N-n(n+1)}{2(n+1)}$$
The number $n$ will sometimes be greater than the number of sums equal to $N$ but it will never be less. Here is a table showing the results for
$\quad 1\le N\le 25$
\begin{align*}
(N,n)\qquad &\text{ consecutive integer sums}\\
(2,0)\qquad &2\\
(3,1)\qquad &3 = 1+2\\
(4,0)\qquad &4\\
(5,1)\qquad &5 = 2+3\\
(6,2)\qquad &6 = 1+2+3\\
(7,1)\qquad &7 = 3+4\\
(8,0)\qquad &8\\
(9,2)\qquad &9 = 4+5\quad = 2+3+4\\
(10,3)\qquad &10 = 1+2+3+4\\
(11,1)\qquad &11 = 5+6\\
(12,2)\qquad &12 = 3+4+5\\
(13,1)\qquad &13 = 6+7\\
(14,3)\qquad &14 = 2+3+4+5\\
(15,4)\qquad &15 = 7+8 \quad = 4+5+6 \quad = 1+2+3+4+5\\
(16,0)\qquad &16\\
(17,1)\qquad &17=8+9\\
(18,4)\qquad &18=5+6+7\quad =3+4+5+6\\
(19,1)\qquad &19=9+10\\
(20,4)\qquad &20 =2+3+4+5+6\\
(21,6)\qquad &21=1+2+3+4+5+6\quad =6+7+8=10+11\\
(22,3)\qquad &22=4+5+6+7+8\\
(23,1)\qquad &23=11+12\\
(24,1)\qquad &24=7+8+9\\
(25,4)\qquad &25=3+4+5+6+7\quad =12+13\\
\end{align*}