<s>[INST] General formula for two sequences Please help me to find general 'analytical' formula fot these two sequences $\{x_n\}$, $n=1,2,3,\ldots$.
I. $0, 1, 2, 2, 3, 6, 6, 7, 14, 14, \ldots$
This meens the following.
$x_{1}=0$, $x_{2}=x_{1}+1$, $x_{3}=2x_{2}$, $x_{4}=x_{3}$, $\ldots$, $x_{3k-1}=x_{3k-2}+1$, $x_{3k}=2x_{3k-1}$, $x_{3k+1}=x_{3k}$.
II. $1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, \ldots$
That is, $x_{n}=1$ if $n=6k-5$, $k=1,2,3,\ldots$; $x_{n}=0$ otherwise.
I tried to use something like
$$
x_{n}=\frac{(-1)^{n-1}+1}{2},
$$
so, we get $1, 0, 1, 0, 1, 0, \ldots$ but I need 5 zeroes after 1.
 [/INST] For case II), shift the index to start from $0$ i.e. put $n=m+1$.
Then you have a function of period $6$:
$$
f\left( m \right) = \left\{ \begin{gathered}
  1\quad \left| {\;\bmod \left( {m,6} \right) = 0} \right. \hfill \\
  0\quad \left| {\;\bmod \left( {m,6} \right) \ne 0} \right. \hfill \\ 
\end{gathered}  \right.
$$
There are plenty of ways to render it. Some are:
a) Floor
Delta of step functions
$$
f\left( x \right) = \left\lfloor {\frac{x}
{6}} \right\rfloor  - \left\lfloor {\frac{{x - 1}}
{6}} \right\rfloor  = 1 + \left\lfloor {\frac{x}
{6}} \right\rfloor  - \left\lceil {\frac{x}
{6}} \right\rceil \quad  \Rightarrow \quad x_n  = \left\lfloor {\frac{{n - 1}}
{6}} \right\rfloor  - \left\lfloor {\frac{{n - 2}}
{6}} \right\rfloor 
$$
b) Discrete Fourier Transform
Taking the real part of the DFT gives:
$$
f\left( x \right) = \frac{1}
{6}\sum\limits_{0\, \leqslant \,k\, \leqslant \,5} {\cos \left( {\frac{{2\pi \,k\,x}}
{6}} \right)} 
$$
c) Discrete Cosine Tranform
Applying the DCT you get instead:
$$
\begin{gathered}
  f\left( x \right) = \frac{1}
{6}\left( {1 + \cos \left( {\pi \,x} \right) + 2\cos \left( {\frac{{\pi \,x}}
{3}} \right) + 2\cos \left( {\frac{{2\pi \,x}}
{3}} \right)} \right) =  \hfill \\
   = \frac{1}
{6}\left( {4\cos ^2 \left( {\frac{{\pi \,x}}
{3}} \right) + 2\cos \left( {\frac{{\pi \,x}}
{3}} \right) + \cos \left( {\pi \,x} \right) - 1} \right) \hfill \\ 
\end{gathered} 
$$
</s>