What general function can I use to represent the next sequence: 2,2,2,2,2,3,3,2,2,2,2,2,3,3,2,2,2,2,2,3,3…? Look at this sequence:
2,2,2,2,2,3,3,2,2,2,2,2,3,3,2,2,2,2,2,3,3...

It is defined as follows:
$$f(n)=\begin{cases}
3 &\text{if $n \bmod 7=6,0$}\\
2 &\text{otherwise}\\
\end{cases}$$
David found a good representation for $f(n)$:
$$g(n)=\frac{\sin\dfrac{2\pi(n+1)}{7}}{\sin\dfrac{2\pi}{7}}
   \frac{\sin\dfrac{2\pi(n+2)}{7}}{\sin\dfrac{4\pi}{7}}\cdots
   \frac{\sin\dfrac{2\pi(n+6)}{7}}{\sin\dfrac{12\pi}{7}}\ ;$$
$$f(n)=2+g(n)+g(n+1)\ ;$$
What is a general representation of $f(n)$ that defined as fallow:
$$f'(n)=\begin{cases}
a &\text{if $n \bmod c=0$ or in the range of  $\{c-d,c-1\}$}\\
b &\text{otherwise}
\end{cases}$$


*

*$a,b,c,d$ are known positive integeres


To be more specific I have 
$$h(n)=y - \sum_{0}^{n}{f'(n)}$$


*

*$y$ is a know positive integer


And $h(n)$ is defined as fallow:
$$h(n) = \frac{e}{n}$$


*

*$e$ is a known positive integer


How do I find $n$?
 A: If I understand what you are asking, we can define
$$
\newcommand{\flfrac}[2]{\left\lfloor\frac{#1}{#2}\right\rfloor}
f(n)=b+(a-b)\left(\flfrac{n+d}c-\flfrac{n-1}c\right)\tag{1}
$$
then
$$
f(n)=\left\{\begin{array}{}
a&\text{if }n\equiv c-d\dots c\pmod{c}\\
b&\text{if }n\equiv1\dots c-d-1\pmod{c}
\end{array}\right.\tag{2}
$$
Next we compute
$$
\begin{align}
\sum_{k=0}^n\flfrac km
&=\sum_{k=0}^{qm-1+r+1}\flfrac km\\
&=\overbrace{m\frac{(\color{#0000FF}{q}-1)\color{#0000FF}{q}}2}^{\text{$m$ copies of $0\dots q-1$}}+\overbrace{(\color{#C00000}{r}+1)\color{#0000FF}{q}\vphantom{\frac{()}2}}^{\text{$r+1$ copies of $q$}}\\
&=\left(\frac{m\left(\color{#0000FF}{\flfrac nm}-1\right)}2+\color{#C00000}{n-m\flfrac nm}+1\right)\color{#0000FF}{\flfrac nm}\\
&=\left(n+1-\frac{m\left(\flfrac nm+1\right)}2\right)\flfrac nm\tag{3}
\end{align}
$$
Now, apply $(3)$ to
$$
\begin{align}
\sum_{k=0}^n\left(\flfrac{k+d}c-\flfrac{k-1}c\right)
&=\sum_{k=0}^{n+d}\flfrac kc-\sum_{k=0}^{d-1}\flfrac kc-\sum_{k=0}^{n-1}\flfrac kc+\sum_{k=0}^{-2}\flfrac kc\\
&=\sum_{k=0}^{n+d}\flfrac kc-\sum_{k=0}^{d-1}\flfrac kc-\sum_{k=0}^{n-1}\flfrac kc+1\tag{4}
\end{align}
$$
