Explicit sum formula for repeated integers I know that $\sum_{i=0}^{n-1} i = \frac{n(n-1)}{2}$, but I am having troubles with finding an explicit sum formula for:
$ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3\dotsc$
The sum sequence of which would be:
$ 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 22, 24, 27, \dotsc$
I thought about converting my sequence to $0,1,2,3,\dotsc$ by doing something with $\lfloor\frac{i}{8}\rfloor$, summing over that and then converting back, but I can't manage to work it out. Any thoughts?
 A: I love this question, because i've studied those periodic shifts myself and led me toward tons beautiful methodes of summation. 
Anyway the general answer is if you start at 0:
$$\sum_{n=0}^{dp} \sum_{z=0}^{d-1}f(n-z)\sum_{k=}^{d-1} (e^{\frac{2i\pi k}{d}})^{n-z}=\sum^p_{n=0} d^2 f(nd)$$
However i'd prefer to start at 1:
$$\sum_{n=1}^{dp} \sum_{z=0}^{d-1}f(n+z)\sum_{k=0}^{d-1} (e^{\frac{2i\pi k}{d}})^{n+z}=\sum^p_{n=1} d^2 f(nd)$$
Your periode of d=8 and f(n)=n will give the new function.
$$1/64\sum_{z=0}^{7}f(n+z)\sum_{k=0}^{7} (e^{\frac{2i\pi k}{8}})^{n+z}
$$ 
You will get 1,1,1,1,1,1,1,1,2...
Take the summation over that and you have your answer. If you wish to get an exact soltution there are serveral ways to solve these, but since your periode is 8, i'm not going to write it down. What i found the easiest myself was to take the delta of an answer you'd expect. ( like $n*(e^{\frac{2i\pi k}{d}})$) And work back. Since this is a simple example, i assume you should be able to solve it now.
I'll provide you an example in case d=2.
$$\sum_{n=1}^{m} (2n+1-(-1)^n)/4=$$
$$m^2/4+m/2-(-1)^m/8+1/8=$$
A: Nevermind, I found it:
$S(n) = \lfloor\frac{n}{8}\rfloor \cdot (n - 4\lfloor\frac{n}{8}\rfloor-4)$
(Note that the indices are really shifted by 1 compared to the original question, but that is actually what I wanted.)
