formula derivation for periodic signal power Studying DSP on my own. Taking an introductory class. Was given a formula for signal power

$$ P = \lim_{M\to\infty} {\frac{1}{2M+1} \sum_{n=-M}^M} \lvert x[n] \rvert^2 $$

I do understand why the formula looks the way it does. 

But then we were given a formula for a power of a periodic signal, where $N$ is the period,

$$ P = {\frac{1}{N} \sum_{n=0}^{N-1}} \lvert x[n] \rvert^2 $$

I can't figure out how this formula is derived from the original one. How do I do it?
I'd like to show you a more formal derivation. Note that the first formula for arbitrary (non-periodic) signals could be rewritten as

$$P_x=\lim_{M\rightarrow\infty}\frac{1}{(2M+1)N}\sum_{n=-MN}^{(M+1)N-1}|x[n]|^2\tag{1}$$

for some integer $N\ge 1$. For $N=1$, Eq. $(1)$ is identical with the first formula in your question. If you choose $N&gt;1$ you simply add more chunks of length $N$ (instead of length $1$) to your sum if you increase $M$.

Now assume that the signal $x[n]$ is periodic with period $N$. This means that the sum over $2M+1$ periods equals $(2M+1)$ times the sum over a single period:

$$\sum_{n=-MN}^{(M+1)N-1}|x[n]|^2=(2M+1)\sum_{n=0}^{N-1}|x[n]|^2\tag{2}$$

Plugging $(2)$ into $(1)$ gives

$$P_x=\lim_{M\rightarrow\infty}\frac{1}{(2M+1)N}(2M+1)\sum_{n=0}^{N-1}|x[n]|^2=\frac{1}{N}\sum_{n=0}^{N-1}|x[n]|^2\tag{3}$$