Is there a formula for the pattern $1,1,1,0,1,0,1,0,1,0\ldots$? Or a mathematical principle?

2.2k Views Asked by At

Starting from $n= 0$:

$1,1,1,0,1,0,1,0,1,0\ldots$

The $0,1,0,1$ pattern keeps on going. Is there a formula for this?

6

There are 6 best solutions below

2
On

You could define it this way: $$n_k=\begin{cases}1, &\text{ if }k=0,1\\ \frac{1}{2}\left((-1)^k+1)\right),&\text{ if }k\ge 2\end{cases}.$$ Or if you want a completely closed formula, you could use $$n_k=\frac{1}{2}\left(1-\frac{1}{2}\big(1-(-1)^{k!}\big)\right)\big((-1)^k+1\big)+\frac{1}{2}\big(1-(-1)^{k!}\big).$$

I actually figured out a better formula. Try $$n_k=\frac{1}{2}\left(1+(-1)^k\right)+\left(1-\frac{1}{2}\left(1+(-1)^{k\cdot k!}\right)\right).$$ Note that the first term describes the sequence $1 , 0, 1, 0, \dots$ while the second term describes the sequence $0,1,0,0,0,0,\dots$. So, adding gives $1,1,1,0,1,0,1,0,\dots$.

0
On

Try this one:

\begin{align} f(n)&= 1-\operatorname{sgn}(n-1)\cdot(n\bmod2) \end{align}

Edit

Here

\begin{align} \operatorname{sgn}(n)&= \begin{cases} -1,\quad n<0\\ \phantom{-}0,\quad n=0\\ \phantom{-}1,\quad n>0 \end{cases} . \end{align}

The function $f$ works as follows:

for all even $n\ge0$ we have $(n\bmod2)=0$, hence $f(n)=1-\operatorname{sgn}(n-1)\cdot0=1$;

for $n=1$ the term $\operatorname{sgn}(n-1)=0$, hence $f(n)=1-0\cdot(n\bmod2)=1$;

and for all odd $n>1$, $f(n)=1-\operatorname{sgn}(n-1)\cdot(n\bmod2)=1-1\cdot1=0$.

Edit2

More exotic function that produces the same output as $f$ for $x=0,1,2,\dots$:

enter image description here

\begin{align} g(x)&= 1+\sin \left( \tfrac\pi2\,\cos(\tfrac\pi2\,x) -\arctan(x-1) -\tfrac12\,\arcsin\left({\tfrac{2\,(x-1)}{{x}^{2}-2\,x+2}}\right) \right) . \end{align}

2
On

$$\frac{1099}{9900} = 0.111010101\dots$$

0
On

The Online Encyclopedia of Integer Sequences has a few interesting results, including http://oeis.org/A266591:

"Middle column of the "Rule 37" elementary cellular automaton starting with a single ON (black) cell."

0
On

orlp's answer, ${1099\over9900} =0.111010101…$, uses decimal arithmetic to produce the desired sequence (as digits of a number). A similar result, but using base 2, is as follows:

$$0.111010101…_2 = {1\over4}+0.101010101…_2= {1\over4}+ {1\over2}\sum\limits_{j=0}^\infty({1\over4})^j ={1\over4}+ {1\over2}\times {4\over3}= {11\over12}$$

That is, the binary representation of base-10 fraction ${11\over12}$ is $0.111010101…_2$.

0
On

The formula of the sequence is $$a_n=\begin{cases} 0, &\text{ if }n \text{ is odd and }n \neq 1 \\ 1,&\text{ if }n \text{ is even or } n=1 \end{cases}. $$ That's all. There is no simpler formula. You could replace "$\text{if }n \text{ is even or } n=1$" by "$\text{otherwise}$", if you prefer that notation. Trying to write this without a case split makes things unnecessary complicated. Interpreting the sequence as digits of a number, as some answers do, only makes sense if you know that the sequence actually represents digits of a number. The pattern is simply too basic to have a deeper meaning.