There are $N$ students and $M$ types of chocolates. How many ways are there to distribute the chocolates to the students given that, no more than two consecutive numbered students, gets the same type of chocolate.
I was able to figure out a case, when $N\geq M$, and that would be $$M^N - \begin{pmatrix}N\\2\end{pmatrix}\cdot\begin{pmatrix}N\\3\end{pmatrix}\cdots\begin{pmatrix}N\\N-1\end{pmatrix}$$
The number of chocolates are infinite. There's just $M$ types of chocolates.
Hint. Divide the problem in two distinct parts.
1) How many ways are there to distribute the chocolates to the students given that, no two consecutive numbered students gets the same type of chocolate? $$\underbrace{(M)}_{\text{student $1$}}\cdot \underbrace{(M-1)}_{\text{student $2$}}\cdots \underbrace{(M-1)}_{\text{student $N$}}=M(M-1)^{N-1}.$$
2) How many ways are there to distribute the chocolates to the students given that, exactly two consecutive numbered students gets the same type of chocolate? We may select the couple of consecutive students in $N-1$ ways. Now consider such couple as a unique student and use 1). What formula do we get for this case?
The final answer is the sum of the numbers obtained in 1) and 2).