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.
 A: The second one can be written as:
$$x_n=1-{\big\lceil\dfrac{n \mod 6 -1}{6}\big\rceil}$$
where we can write $n\mod 6$ as:
$$n \mod 6=n-6\big\lfloor\dfrac{n}{6}\big\rfloor$$
This definition of mod returns $0\dots5$ however, and so subtracting $1$ yields a return value in $-1\dots4$. We want to differentiate between $0$ and the other values, and so we can use the abs function ($||$)to take the absolute value of the return value:
$$x_n=1-{\big\lceil\dfrac{|n-6\big\lfloor\dfrac{n}{6}\big\rfloor-1|}{6}\big\rceil}$$
The abs function is defined as:
$$\operatorname{abs}(x)=\sqrt{x^2}$$
and so a full analytic definition of $x_n$ is:
$$x_n=1-{\big\lceil\dfrac{\sqrt{(n-6\big\lfloor\dfrac{n}{6}\big\rfloor-1)^2}}{6}\big\rceil}$$
I can't think of simple definitions for the floor or ceiling functions ($\lfloor\;\rfloor$, $\lceil\;\rceil$) at the moment.
A: 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} 
$$
