# $X\sim DU(n)$ show that the moment generating function of $X$ is $M_x(t)=\frac{e^t-e^{(n+1)t}}{n(1-e^t)}$

We are give the $pmf$ by: $f(x) = P(X=x) =\frac{1}{n}$ for $x=1,2,...,n$. and $0$ otherwise. This is a discrete case. So I know that I am using the formula $M_x(t)=\sum\limits_{X} e^{tx}\cdot p(x)$. I have the sum $\frac{1}{n}(e^t+e^{2t}+e^{3t} +...+e^{nt})$. Next I factored a $t$ out of the exponent to arrive at $\frac{1}{n}(e^{t(1+2+3+...+n)})$ and then $\frac{1}{n}(e^{t\frac{n(n+1)}{2}})$ I am not sure how to break this apart. Any help would be appreciated, thanks

Do you remember the formula of the sum of a geometric sequence?

i.e. $$S_n=\frac{a_1-a_nq}{1-q}$$

where $S_n$ is the sum, $q$ is the common ratio, $a_1$ is the first item of the sequence, $a_n$ is the last item of the sequence.

$\frac{1}{n}(e^t+e^{2t}+e^{3t} +...+e^{nt}) \ne \frac{1}{n}(e^{t(1+2+3+...+n)})$
$\frac{1}{n}(e^t*e^{2t}*e^{3t}*...*e^{nt})= \frac{1}{n}(e^{t(1+2+3+...+n)})$