# When is the sequence composed only by 1 and 2 where the number of 1 is infinite? And when is $d_n$ a constant?

{$a_n$} ($n\ge 1$) is a infinite sequence composed by non negative integers. The maximum among its first n terms is $A_n$, the minimum among $a_{n+1}$,$a_{n+2}$,... is denoted by $B_n$, and $d_n=A_n-B_n$.

Question:

1) What is the necessary and sufficient condition for {$a_n$} to be only composed by 1 or 2, and there are infinitely many 1s? for example,{1,2,1,1,2,1,1,1,1,1,1,1...}
Remark, the number of 2s could be finite or infinite, however, there are infinitely many 1s.

2) If $a_1=2$, $d_n=1$, will the sequence possess the properties described in 1)? If it will, then prove it.

3) Find the necessary and sufficient condition for $d_n=-d$, where d is a non negative integer.

1) If set $\{n\in \mathbb Z_{>0}|a_n=1\}$ is infinite and $a_n\in\{1,2\}$ for each $n$ then $B_n=1$ for each $n$, $A_1>0$ and $A_n\le 2$ for each $n$. These conditions are not only necessary but also sufficient. $A_n\le 2$ ensures that $a_n\in \{0,1,2\}$ for each $n$. $B_n=1$ for each $n$ ensures that set $\{n\in \mathbb Z_{>0}|a_n=1\}$ is infinite. $B_1=1$ ensures that $a_n\ne0$ for $n>1$. Finally $A_1>0$ ensures that $a_1\ne 0$.
2) The answer is yes. First we will show that $a_n\in \{1,2\}$ for each $n$. Suppose that this is not true and let $k$ be the smallest integer such that $a_{k}\notin\left\{ 1,2\right\}$. Then $k\geq2$, since $a_1=2$. If $a_{k}=0$ then $B_{1}=0$. But from $a_{1}=2$ it also follows that $A_{1}=2$ and consequently $d_{1}=2$. This allows us to conclude that $a_{k}\ne0$. Then $a_{k}\geq3$ and the minimality of $k$ combined with $a_1=2$ tells us that $A_{k-1}=2$ and $A_{k}=a_{k}$. Based on $d_{k-1}=d_{k}=1$ we find that $B_{k-1}=1$ and $B_{k}=a_{k}-1$. However, then $B_{k-1}=\min\left\{ a_{k},B_{k}\right\} =a_{k}-1\geq2$ and a contradiction is found. Proved is now that $a_n\in\{1,2\}$ for each $n$. So if the sequence does not posses the properties described in 1) then the set $\{n|a_n=1\}$ must be finite. Combined with $a_n\in \{1,2\}$ for each $n$ and $a_1=2$ that leads to $A_n=B_n=2$ (hence $d_n=0$) for $n$ large enough. Again a contradiction. This completes the proof.
3) Assume that $d_{n}=-d$ where $d$ is a nonnegative integer. Then $B_{n}=A_{n}+d\geq A_{n}$ and consequently $a_{n+1}\geq B_{n}\geq A_{n}\geq a_{n}$. So the sequence is non-decreasing, wich leads to $a_{n+1}=B_{n}=A_n+d=a_{n}+d$. This condition is evidently sufficient too. We find that $a_n=c+nd$ for some constant $c$.
• I misunderstood and thought that some $n$ would exist with $a_k=1$ for each $k\ge n$. Repaired. Apr 4 '14 at 7:58
• $A_n\le 2$ for each n only ensures that the sequence is only composed by 0,1 or 2. Thus the sequence could contain 0. Your answer is not sufficient. Apr 4 '14 at 8:16
• The sequence cannot contain a $0$ since $B_n=1$ for each $n$. See my edit. Apr 4 '14 at 8:38