What is the proof that subtracting $1$ from each term of integer sequence $A003278$ gives integer sequence $A005836?$

99 Views Asked by At

This is a follow-up question to the comments in this question.

The definition of A003278 I would like to work from is: "$a(1) = 1, a(2) = 2$, and thereafter $a(n)$ is smallest number $k$ which avoids any $3$-term arithmetic progression in $a(1), a(2), ..., a(n-1), k.$"

Apparently this sequence is the same as the sequence: "$a(n)-1$ in ternary = $n-1$ in binary". Question $1$: Why are these two sequences the same (what is a proof)?

Secondly, the second comment on the $A003278$ page:

Subtracting 1 from each term gives A005836 (ternary representation contains no $2$'s). - N. J. A. Sloane, Dec 01 2019

Question $2$: What is the proof that subtracting $1$ from each term of integer sequence $A003278$ gives integer sequence $A005836$ ?

1

There are 1 best solutions below

5
On

If $a(n)$ ($n\geq 1$) denotes A003278, then $b(n)=a(n+1)-1$ ($n\geq 1$) has the property that $b(n)$ in ternary is $n$ in binary, and $b(n)=c(n+1)$ where $c$ denotes A005836, and $c(n+1)$ is just the sequence of non-zero numbers whose base $3$ representation contains no $2$. In other words, we have to prove that the sequences (where $n\geq 1$):

$b(n)$: the number such that $b(n)$ in ternary is $n$ in binary.

and

$c(n+1)$: the $n$-th non-zero number whose base $3$ representation contains no $2$.

are identical.

Notice that by taking the definition of $b$ "in reverse", it's trivial to generate it: to get $b(n)$, you just write down $n$ in binary and interpret it in ternary. But this clearly also generates all of the non-zero (because we start at $n=1$) numbers whose base $3$ representation contains no $2$. The only detail we need to attend to is to show that $b(n)$ is an increasing sequence, which doesn't immediately follow from its definition. If it weren't, then $b$ might only be a permutation of $c(n+1)$, not term-for-term the same sequence.

Basically we have to show that if a bitstring $s$ is greater than a bitstring $t$ as a binary number, then it is also greater than $t$ as a ternary number. This is not too hard if we just think about when one binary number is greater than another. Pad the shorter one with leading zeros if necessary so $s$ and $t$ are the same length. Now scan both strings from left to right, until you hit the first index $i$ at which $s[i]\neq t[i]$. Since $s$ as a binary number is greater than $t$ as a binary number, we must in fact have $s[i]=1$ and $t[i]=0$. This implies that $s$ must be greater than $t$ as a ternary number as well, since $3^i>\sum_{j<i}3^j$.