Skip to main content
Bounty Ended with 50 reputation awarded by CommunityBot
minor spacing and comment about modular relations in general case
Source Link
Robin Zhang
  • 394
  • 5
  • 13

To write the $k=3$ solution in closed form, we have \begin{align*} \Delta_n &= \sum_{i = 0}^{\lfloor \log_3 n\rfloor + 1} \delta_i(n), \end{align*}

where, letting $n = (n_\ell \ldots {n_1})_3$ denote the ternary expansion of $n$, we define $\delta_i(n)$ for $i = 0, 1, 2$ to be

\begin{align*} \delta_0(n) &= 9 \\ \delta_1(n) &= \begin{cases} -3 & \text{if } n \equiv 2 \pmod 3 \\ 0 & \text{else} \end{cases} \\ \delta_2(n) &= \begin{cases} 1 & \text{if } n \equiv 12_3 \text{ or } 22_3\pmod9\\ -1 & \text{if } n \equiv 20_3 \text{ or } 21_3\pmod9\\ 0 & \text{else} \end{cases}. \end{align*}

Before we define $\delta_i$ in general, let \begin{align*} (12)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell} \\ (21)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell + 1}. \end{align*} Then $(12)_3^{(i)}$ has $i$-many ternary digits and is either of the form $12...12$ or $21....12$ depending on the parity of $i$ (e.g. $(12)_3^{(2)} = 12_3$ and $(12)_3^{(3)} = 212_3$). Similarly, $(21)_3^{(i)}$ has $i$-many ternary digits and is either of the form $21...21$ or $12...21$ depending on the parity of $i$.

Then define \begin{align*} \delta_i(n) &:= \begin{cases} (-1)^{i} & \text{if } n \equiv (21)_3^{(i)} \text{ or } 3^2(21)_3^{(i-2)} + 22_3\pmod {3^i}\\ (-1)^{i+1} & \text{if } n \equiv (12)_3^{(i)} \text{ or } 3^2(12)_3^{(i-2)} + 20_3 \pmod {3^i}\\ 0 & \text{else} \end{cases} \\ \end{align*} for all $i > 2$.


Observe that this is actually equivalent to the finite state machine given by Bullet51. Plus, this gives that $\Delta_{3n} + \Delta_{3n+1} + \Delta_{3n+2} = 24$ for any $n$ since $$\delta_i(3n) + \delta_{i}(3n+1) + \delta_{i}(3n+2) = \begin{cases}27 & \text{if } i=0 \\ -3 & \text{if } i=1 \\ 0 & \text{if } i > 1\end{cases}.$$ Similarly, we can express the other finite state machines for larger $k$ in terms of $\delta_i$ with conditions modulo $k^i$.

To explain such a formula, we can examine how the $x_n$ changes $\Delta_n$. Suppose $x_n$ appears in the expression for $x_{n'}$, i.e. $x_{n'} = a + b + c$ where $x_n$ is one of $a$, $b$, or $c$. Always writing $a \leq b \leq c$ and assigning the convention that $x_n = a$ if $a \neq b$, $x_n = b$ if $a=b$ and $x_n = c$ if $b=c$, then define $$ y_n := \begin{cases} 0 & \text{if } x_n = a \\ 1 &\text{if } x_n = b \\ 2 &\text{if } x_n = c \end{cases} $$ to be the position of $x_n$ in the expression of $x_{n'}$. Then observe that $x_{n'} \equiv y_n \pmod 3$. But also observe that $y_n$ depends on $\Delta_{n-1}$ modulo $3$: $$ y_n = \begin{cases} y_{n-1} & \text{if } \Delta_{n-1} \equiv 2 \pmod 3 \\ y_{n-1} + 1 & \text{if } \Delta_{n-1} \equiv 0 \pmod 3 \\ y_{n-1} + 2 & \text{if } \Delta_{n-1} \equiv 1 \pmod 3 \end{cases}. $$ If we chase through these modular relations, we can then build the expression for $\Delta_n$ that we have above as well as the finite state machines that have been given here. This is somewhat tricky but we can start with the fact that we expect $\Delta_n$ to be $9$ if $n+1$ and $n$ are not $m'$ for some $m$ (i.e. no other $x_m$ appears in their expression as the sum of three integers), we expect it to be $6$ if no $x_m$ appears in the expression for $x_n$ but does for $x_{n+1}$ with $y_m = 0$. Then we have these corrections $\delta_i = \pm 1$ (with $i > 1$) in the other cases.


While this should work for the analogous situations with other fixed $k$, the situation becomes more complicated for general $k$ and it is not immediately clear what a general formula would look like. However one can deduce the closed form for any $k$ by looking at the modular relation $x_{n’} \equiv y_n \pmod k$$x_{n’}$ and $y_n$ modulo $k$ and the relation between $y_n$ and $\Delta_{n-1}$ modulo $k$.

Also note that if we define $A$ using $\{m \in \mathbb{Z} \mid m > \ell \}$ with $\ell \geq 0$ instead of $\mathbb{N}$, we will get something extremely similar to this.

To write the $k=3$ solution in closed form, we have \begin{align*} \Delta_n &= \sum_{i = 0}^{\lfloor \log_3 n\rfloor + 1} \delta_i(n), \end{align*}

where, letting $n = (n_\ell \ldots {n_1})_3$ denote the ternary expansion of $n$, we define $\delta_i(n)$ for $i = 0, 1, 2$ to be

\begin{align*} \delta_0(n) &= 9 \\ \delta_1(n) &= \begin{cases} -3 & \text{if } n \equiv 2 \pmod 3 \\ 0 & \text{else} \end{cases} \\ \delta_2(n) &= \begin{cases} 1 & \text{if } n \equiv 12_3 \text{ or } 22_3\pmod9\\ -1 & \text{if } n \equiv 20_3 \text{ or } 21_3\pmod9\\ 0 & \text{else} \end{cases}. \end{align*}

Before we define $\delta_i$ in general, let \begin{align*} (12)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell} \\ (21)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell + 1}. \end{align*} Then $(12)_3^{(i)}$ has $i$-many ternary digits and is either of the form $12...12$ or $21....12$ depending on the parity of $i$ (e.g. $(12)_3^{(2)} = 12_3$ and $(12)_3^{(3)} = 212_3$). Similarly, $(21)_3^{(i)}$ has $i$-many ternary digits and is either of the form $21...21$ or $12...21$ depending on the parity of $i$.

Then define \begin{align*} \delta_i(n) &:= \begin{cases} (-1)^{i} & \text{if } n \equiv (21)_3^{(i)} \text{ or } 3^2(21)_3^{(i-2)} + 22_3\pmod {3^i}\\ (-1)^{i+1} & \text{if } n \equiv (12)_3^{(i)} \text{ or } 3^2(12)_3^{(i-2)} + 20_3 \pmod {3^i}\\ 0 & \text{else} \end{cases} \\ \end{align*} for all $i > 2$.


Observe that this is actually equivalent to the finite state machine given by Bullet51. Plus, this gives that $\Delta_{3n} + \Delta_{3n+1} + \Delta_{3n+2} = 24$ for any $n$ since $$\delta_i(3n) + \delta_{i}(3n+1) + \delta_{i}(3n+2) = \begin{cases}27 & \text{if } i=0 \\ -3 & \text{if } i=1 \\ 0 & \text{if } i > 1\end{cases}.$$ Similarly, we can express the other finite state machines for larger $k$ in terms of $\delta_i$ with conditions modulo $k^i$.

To explain such a formula, we can examine how the $x_n$ changes $\Delta_n$. Suppose $x_n$ appears in the expression for $x_{n'}$, i.e. $x_{n'} = a + b + c$ where $x_n$ is one of $a$, $b$, or $c$. Always writing $a \leq b \leq c$ and assigning the convention that $x_n = a$ if $a \neq b$, $x_n = b$ if $a=b$ and $x_n = c$ if $b=c$, then define $$ y_n := \begin{cases} 0 & \text{if } x_n = a \\ 1 &\text{if } x_n = b \\ 2 &\text{if } x_n = c \end{cases} $$ to be the position of $x_n$ in the expression of $x_{n'}$. Then observe that $x_{n'} \equiv y_n \pmod 3$. But also observe that $y_n$ depends on $\Delta_{n-1}$ modulo $3$: $$ y_n = \begin{cases} y_{n-1} & \text{if } \Delta_{n-1} \equiv 2 \pmod 3 \\ y_{n-1} + 1 & \text{if } \Delta_{n-1} \equiv 0 \pmod 3 \\ y_{n-1} + 2 & \text{if } \Delta_{n-1} \equiv 1 \pmod 3 \end{cases}. $$ If we chase through these modular relations, we can then build the expression for $\Delta_n$ that we have above as well as the finite state machines that have been given here. This is somewhat tricky but we can start with the fact that we expect $\Delta_n$ to be $9$ if $n+1$ and $n$ are not $m'$ for some $m$ (i.e. no other $x_m$ appears in their expression as the sum of three integers), we expect it to be $6$ if no $x_m$ appears in the expression for $x_n$ but does for $x_{n+1}$ with $y_m = 0$. Then we have these corrections $\delta_i = \pm 1$ (with $i > 1$) in the other cases.


While this should work for the analogous situations with other fixed $k$, the situation becomes more complicated for general $k$ and it is not immediately clear what a general formula would look like. However one can deduce the closed form for any $k$ by looking at the modular relation $x_{n’} \equiv y_n \pmod k$ and the relation between $y_n$ and $\Delta_{n-1}$ modulo $k$.

Also note that if we define $A$ using $\{m \in \mathbb{Z} \mid m > \ell \}$ with $\ell \geq 0$ instead of $\mathbb{N}$, we will get something extremely similar to this.

To write the $k=3$ solution in closed form, we have \begin{align*} \Delta_n &= \sum_{i = 0}^{\lfloor \log_3 n\rfloor + 1} \delta_i(n), \end{align*}

where, letting $n = (n_\ell \ldots {n_1})_3$ denote the ternary expansion of $n$, we define $\delta_i(n)$ for $i = 0, 1, 2$ to be

\begin{align*} \delta_0(n) &= 9 \\ \delta_1(n) &= \begin{cases} -3 & \text{if } n \equiv 2 \pmod 3 \\ 0 & \text{else} \end{cases} \\ \delta_2(n) &= \begin{cases} 1 & \text{if } n \equiv 12_3 \text{ or } 22_3\pmod9\\ -1 & \text{if } n \equiv 20_3 \text{ or } 21_3\pmod9\\ 0 & \text{else} \end{cases}. \end{align*}

Before we define $\delta_i$ in general, let \begin{align*} (12)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell} \\ (21)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell + 1}. \end{align*} Then $(12)_3^{(i)}$ has $i$-many ternary digits and is either of the form $12...12$ or $21....12$ depending on the parity of $i$ (e.g. $(12)_3^{(2)} = 12_3$ and $(12)_3^{(3)} = 212_3$). Similarly, $(21)_3^{(i)}$ has $i$-many ternary digits and is either of the form $21...21$ or $12...21$ depending on the parity of $i$.

Then define \begin{align*} \delta_i(n) &:= \begin{cases} (-1)^{i} & \text{if } n \equiv (21)_3^{(i)} \text{ or } 3^2(21)_3^{(i-2)} + 22_3\pmod {3^i}\\ (-1)^{i+1} & \text{if } n \equiv (12)_3^{(i)} \text{ or } 3^2(12)_3^{(i-2)} + 20_3 \pmod {3^i}\\ 0 & \text{else} \end{cases} \\ \end{align*} for all $i > 2$.


Observe that this is actually equivalent to the finite state machine given by Bullet51. Plus, this gives that $\Delta_{3n} + \Delta_{3n+1} + \Delta_{3n+2} = 24$ for any $n$ since $$\delta_i(3n) + \delta_{i}(3n+1) + \delta_{i}(3n+2) = \begin{cases}27 & \text{if } i=0 \\ -3 & \text{if } i=1 \\ 0 & \text{if } i > 1\end{cases}.$$ Similarly, we can express the other finite state machines for larger $k$ in terms of $\delta_i$ with conditions modulo $k^i$.

To explain such a formula, we can examine how the $x_n$ changes $\Delta_n$. Suppose $x_n$ appears in the expression for $x_{n'}$, i.e. $x_{n'} = a + b + c$ where $x_n$ is one of $a$, $b$, or $c$. Always writing $a \leq b \leq c$ and assigning the convention that $x_n = a$ if $a \neq b$, $x_n = b$ if $a=b$ and $x_n = c$ if $b=c$, then define $$ y_n := \begin{cases} 0 & \text{if } x_n = a \\ 1 &\text{if } x_n = b \\ 2 &\text{if } x_n = c \end{cases} $$ to be the position of $x_n$ in the expression of $x_{n'}$. Then observe that $x_{n'} \equiv y_n \pmod 3$. But also observe that $y_n$ depends on $\Delta_{n-1}$ modulo $3$: $$ y_n = \begin{cases} y_{n-1} & \text{if } \Delta_{n-1} \equiv 2 \pmod 3 \\ y_{n-1} + 1 & \text{if } \Delta_{n-1} \equiv 0 \pmod 3 \\ y_{n-1} + 2 & \text{if } \Delta_{n-1} \equiv 1 \pmod 3 \end{cases}. $$ If we chase through these modular relations, we can then build the expression for $\Delta_n$ that we have above as well as the finite state machines that have been given here. This is somewhat tricky but we can start with the fact that we expect $\Delta_n$ to be $9$ if $n+1$ and $n$ are not $m'$ for some $m$ (i.e. no other $x_m$ appears in their expression as the sum of three integers), we expect it to be $6$ if no $x_m$ appears in the expression for $x_n$ but does for $x_{n+1}$ with $y_m = 0$. Then we have these corrections $\delta_i = \pm 1$ (with $i > 1$) in the other cases.


While this should work for the analogous situations with other fixed $k$, the situation becomes more complicated for general $k$ and it is not immediately clear what a general formula would look like. However one can deduce the closed form for any $k$ by looking at the modular relation $x_{n’}$ and $y_n$ modulo $k$ and the relation between $y_n$ and $\Delta_{n-1}$ modulo $k$.

Also note that if we define $A$ using $\{m \in \mathbb{Z} \mid m > \ell \}$ with $\ell \geq 0$ instead of $\mathbb{N}$, we will get something extremely similar to this.

minor spacing and comment about modular relations in general case
Source Link
Robin Zhang
  • 394
  • 5
  • 13

To write the $k=3$ solution in closed form, we have \begin{align*} \Delta_n &= \sum_{i = 0}^{\lfloor \log_3 n\rfloor + 1} \delta_i(n), \end{align*}

where, letting $n = (n_\ell \ldots {n_1})_3$ denote the ternary expansion of $n$, we define $\delta_i(n)$ for $i = 0, 1, 2$ to be

\begin{align*} \delta_0(n) &= 9 \\ \delta_1(n) &= \begin{cases} -3 & \text{if } n \equiv 2 \pmod 3 \\ 0 & \text{else} \end{cases} \\ \delta_2(n) &= \begin{cases} 1 & \text{if } n \equiv 12_3 \text{ or } 22_3\pmod9\\ -1 & \text{if } n \equiv 20_3 \text{ or } 21_3\pmod9\\ 0 & \text{else} \end{cases}. \end{align*}

Before we define $\delta_i$ in general, let \begin{align*} (12)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell} \\ (21)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell + 1}. \end{align*} Then $(12)_3^{(i)}$ has $i$-many ternary digits and is either of the form $12...12$ or $21....12$ depending on the parity of $i$ (e.g. $(12)_3^{(2)} = 12_3$ and $(12)_3^{(3)} = 212_3$). Similarly, $(21)_3^{(i)}$ has $i$-many ternary digits and is either of the form $21...21$ or $12...21$ depending on the parity of $i$.

Then define \begin{align*} \delta_i(n) &:= \begin{cases} (-1)^{i} & \text{if } n \equiv (21)_3^{(i)} \text{ or } 3^2(21)_3^{(i-2)} + 22_3\pmod {3^i}\\ (-1)^{i+1} & \text{if } n \equiv (12)_3^{(i)} \text{ or } 3^2(12)_3^{(i-2)} + 20_3 \pmod {3^i}\\ 0 & \text{else} \end{cases} \\ \end{align*} for all $i > 2$.


Observe that this is actually equivalent to the finite state machine given by Bullet51. Plus, this gives that $\Delta_{3n} + \Delta_{3n+1} + \Delta_{3n+2} = 24$ for any $n$ since $$\delta_i(3n) + \delta_{i}(3n+1) + \delta_{i}(3n+2) = \begin{cases}27 & \text{if } i=0 \\ -3 & \text{if } i=1 \\ 0 & \text{if } i > 1\end{cases}.$$ Similarly, we can express the other finite state machines for larger $k$ in terms of $\delta_i$ with conditions modulo $k^i$.

To explain such a formula, we can examine how the $x_n$ changes $\Delta_n$. Suppose $x_n$ appears in the expression for $x_{n'}$, i.e. $x_{n'} = a + b + c$ where $x_n$ is one of $a$, $b$, or $c$. Always writing $a \leq b \leq c$ and assigning the convention that $x_n = a$ if $a \neq b$, $x_n = b$ if $a=b$ and $x_n = c$ if $b=c$, then define $$ y_n := \begin{cases} 0 & \text{if } x_n = a \\ 1 &\text{if } x_n = b \\ 2 &\text{if } x_n = c \end{cases} $$ to be the position of $x_n$ in the expression of $x_{n'}$. Then observe that $x_{n'} \equiv y_n \pmod 3$. But also observe that $y_n$ depends on $\Delta_{n-1}$ modulo $3$: $$ y_n = \begin{cases} y_{n-1} & \text{if } \Delta_{n-1} \equiv 2 \pmod 3 \\ y_{n-1} + 1 & \text{if } \Delta_{n-1} \equiv 0 \pmod 3 \\ y_{n-1} + 2 & \text{if } \Delta_{n-1} \equiv 1 \pmod 3 \end{cases}. $$ If we chase through these modular relations, we can then build the expression for $\Delta_n$ that we have above as well as the finite state machines that have been given here. This is somewhat tricky but we can start with the fact that we expect $\Delta_n$ to be $9$ if $n+1$ and $n$ are not $m'$ for some $m$ (i.e. no other $x_m$ appears in their expression as the sum of three integers), we expect it to be $6$ if no $x_m$ appears in the expression for $x_n$ but does for $x_{n+1}$ with $y_m = 0$. Then we have these corrections $\delta_i = \pm 1$ (with $i > 1$) in the other cases.


While this should work for the analogous situations with other fixed $k$, the situation becomes quitemore complicated for general $k$ and it is not immediately clear what a general formula would look like. However one can deduce the closed form for any $k$ by looking at the modular relation $x_{n’} \equiv y_n \pmod k$ and the relation between $y_n$ and $\Delta_{n-1}$ modulo $k$.

Also note that if we define $A$ using $\{m \in \mathbb{Z} \mid m > \ell \}$ with $\ell \geq 0$ instead of $\mathbb{N}$, we will get something extremely similar to this.

To write the $k=3$ solution in closed form, we have \begin{align*} \Delta_n &= \sum_{i = 0}^{\lfloor \log_3 n\rfloor + 1} \delta_i(n), \end{align*}

where, letting $n = (n_\ell \ldots {n_1})_3$ denote the ternary expansion of $n$, we define $\delta_i(n)$ for $i = 0, 1, 2$ to be

\begin{align*} \delta_0(n) &= 9 \\ \delta_1(n) &= \begin{cases} -3 & \text{if } n \equiv 2 \pmod 3 \\ 0 & \text{else} \end{cases} \\ \delta_2(n) &= \begin{cases} 1 & \text{if } n \equiv 12_3 \text{ or } 22_3\pmod9\\ -1 & \text{if } n \equiv 20_3 \text{ or } 21_3\pmod9\\ 0 & \text{else} \end{cases}. \end{align*}

Before we define $\delta_i$ in general, let \begin{align*} (12)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell} \\ (21)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell + 1}. \end{align*} Then $(12)_3^{(i)}$ has $i$-many ternary digits and is either of the form $12...12$ or $21....12$ depending on the parity of $i$ (e.g. $(12)_3^{(2)} = 12_3$ and $(12)_3^{(3)} = 212_3$). Similarly, $(21)_3^{(i)}$ has $i$-many ternary digits and is either of the form $21...21$ or $12...21$ depending on the parity of $i$.

Then define \begin{align*} \delta_i(n) &:= \begin{cases} (-1)^{i} & \text{if } n \equiv (21)_3^{(i)} \text{ or } 3^2(21)_3^{(i-2)} + 22_3\pmod {3^i}\\ (-1)^{i+1} & \text{if } n \equiv (12)_3^{(i)} \text{ or } 3^2(12)_3^{(i-2)} + 20_3 \pmod {3^i}\\ 0 & \text{else} \end{cases} \\ \end{align*} for all $i > 2$.


Observe that this is actually equivalent to the finite state machine given by Bullet51. Plus, this gives that $\Delta_{3n} + \Delta_{3n+1} + \Delta_{3n+2} = 24$ for any $n$ since $$\delta_i(3n) + \delta_{i}(3n+1) + \delta_{i}(3n+2) = \begin{cases}27 & \text{if } i=0 \\ -3 & \text{if } i=1 \\ 0 & \text{if } i > 1\end{cases}.$$ Similarly, we can express the other finite state machines for larger $k$ in terms of $\delta_i$ with conditions modulo $k^i$.

To explain such a formula, we can examine how the $x_n$ changes $\Delta_n$. Suppose $x_n$ appears in the expression for $x_{n'}$, i.e. $x_{n'} = a + b + c$ where $x_n$ is one of $a$, $b$, or $c$. Always writing $a \leq b \leq c$ and assigning the convention that $x_n = a$ if $a \neq b$, $x_n = b$ if $a=b$ and $x_n = c$ if $b=c$, then define $$ y_n := \begin{cases} 0 & \text{if } x_n = a \\ 1 &\text{if } x_n = b \\ 2 &\text{if } x_n = c \end{cases} $$ to be the position of $x_n$ in the expression of $x_{n'}$. Then observe that $x_{n'} \equiv y_n \pmod 3$. But also observe that $y_n$ depends on $\Delta_{n-1}$ modulo $3$: $$ y_n = \begin{cases} y_{n-1} & \text{if } \Delta_{n-1} \equiv 2 \pmod 3 \\ y_{n-1} + 1 & \text{if } \Delta_{n-1} \equiv 0 \pmod 3 \\ y_{n-1} + 2 & \text{if } \Delta_{n-1} \equiv 1 \pmod 3 \end{cases}. $$ If we chase through these modular relations, we can then build the expression for $\Delta_n$ that we have above as well as the finite state machines that have been given here. This is somewhat tricky but we can start with the fact that we expect $\Delta_n$ to be $9$ if $n+1$ and $n$ are not $m'$ for some $m$ (i.e. no other $x_m$ appears in their expression as the sum of three integers), we expect it to be $6$ if no $x_m$ appears in the expression for $x_n$ but does for $x_{n+1}$ with $y_m = 0$. Then we have these corrections $\delta_i = \pm 1$ (with $i > 1$) in the other cases.


While this should work for the analogous situations with other fixed $k$, the situation becomes quite complicated for general $k$ and it is not immediately clear what a general formula would look like. Also note that if we define $A$ using $\{m \in \mathbb{Z} \mid m > \ell \}$ with $\ell \geq 0$ instead of $\mathbb{N}$, we will get something extremely similar to this.

To write the $k=3$ solution in closed form, we have \begin{align*} \Delta_n &= \sum_{i = 0}^{\lfloor \log_3 n\rfloor + 1} \delta_i(n), \end{align*}

where, letting $n = (n_\ell \ldots {n_1})_3$ denote the ternary expansion of $n$, we define $\delta_i(n)$ for $i = 0, 1, 2$ to be

\begin{align*} \delta_0(n) &= 9 \\ \delta_1(n) &= \begin{cases} -3 & \text{if } n \equiv 2 \pmod 3 \\ 0 & \text{else} \end{cases} \\ \delta_2(n) &= \begin{cases} 1 & \text{if } n \equiv 12_3 \text{ or } 22_3\pmod9\\ -1 & \text{if } n \equiv 20_3 \text{ or } 21_3\pmod9\\ 0 & \text{else} \end{cases}. \end{align*}

Before we define $\delta_i$ in general, let \begin{align*} (12)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell} \\ (21)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell + 1}. \end{align*} Then $(12)_3^{(i)}$ has $i$-many ternary digits and is either of the form $12...12$ or $21....12$ depending on the parity of $i$ (e.g. $(12)_3^{(2)} = 12_3$ and $(12)_3^{(3)} = 212_3$). Similarly, $(21)_3^{(i)}$ has $i$-many ternary digits and is either of the form $21...21$ or $12...21$ depending on the parity of $i$.

Then define \begin{align*} \delta_i(n) &:= \begin{cases} (-1)^{i} & \text{if } n \equiv (21)_3^{(i)} \text{ or } 3^2(21)_3^{(i-2)} + 22_3\pmod {3^i}\\ (-1)^{i+1} & \text{if } n \equiv (12)_3^{(i)} \text{ or } 3^2(12)_3^{(i-2)} + 20_3 \pmod {3^i}\\ 0 & \text{else} \end{cases} \\ \end{align*} for all $i > 2$.


Observe that this is actually equivalent to the finite state machine given by Bullet51. Plus, this gives that $\Delta_{3n} + \Delta_{3n+1} + \Delta_{3n+2} = 24$ for any $n$ since $$\delta_i(3n) + \delta_{i}(3n+1) + \delta_{i}(3n+2) = \begin{cases}27 & \text{if } i=0 \\ -3 & \text{if } i=1 \\ 0 & \text{if } i > 1\end{cases}.$$ Similarly, we can express the other finite state machines for larger $k$ in terms of $\delta_i$ with conditions modulo $k^i$.

To explain such a formula, we can examine how the $x_n$ changes $\Delta_n$. Suppose $x_n$ appears in the expression for $x_{n'}$, i.e. $x_{n'} = a + b + c$ where $x_n$ is one of $a$, $b$, or $c$. Always writing $a \leq b \leq c$ and assigning the convention that $x_n = a$ if $a \neq b$, $x_n = b$ if $a=b$ and $x_n = c$ if $b=c$, then define $$ y_n := \begin{cases} 0 & \text{if } x_n = a \\ 1 &\text{if } x_n = b \\ 2 &\text{if } x_n = c \end{cases} $$ to be the position of $x_n$ in the expression of $x_{n'}$. Then observe that $x_{n'} \equiv y_n \pmod 3$. But also observe that $y_n$ depends on $\Delta_{n-1}$ modulo $3$: $$ y_n = \begin{cases} y_{n-1} & \text{if } \Delta_{n-1} \equiv 2 \pmod 3 \\ y_{n-1} + 1 & \text{if } \Delta_{n-1} \equiv 0 \pmod 3 \\ y_{n-1} + 2 & \text{if } \Delta_{n-1} \equiv 1 \pmod 3 \end{cases}. $$ If we chase through these modular relations, we can then build the expression for $\Delta_n$ that we have above as well as the finite state machines that have been given here. This is somewhat tricky but we can start with the fact that we expect $\Delta_n$ to be $9$ if $n+1$ and $n$ are not $m'$ for some $m$ (i.e. no other $x_m$ appears in their expression as the sum of three integers), we expect it to be $6$ if no $x_m$ appears in the expression for $x_n$ but does for $x_{n+1}$ with $y_m = 0$. Then we have these corrections $\delta_i = \pm 1$ (with $i > 1$) in the other cases.


While this should work for the analogous situations with other fixed $k$, the situation becomes more complicated for general $k$ and it is not immediately clear what a general formula would look like. However one can deduce the closed form for any $k$ by looking at the modular relation $x_{n’} \equiv y_n \pmod k$ and the relation between $y_n$ and $\Delta_{n-1}$ modulo $k$.

Also note that if we define $A$ using $\{m \in \mathbb{Z} \mid m > \ell \}$ with $\ell \geq 0$ instead of $\mathbb{N}$, we will get something extremely similar to this.

add remark about triples summing to 24
Source Link
Robin Zhang
  • 394
  • 5
  • 13

To write the $k=3$ solution in closed form, we have \begin{align*} \Delta_n &= 9 + \sum_{i = 1}^{\lfloor \log_3 n\rfloor + 1} \delta_i, \end{align*}\begin{align*} \Delta_n &= \sum_{i = 0}^{\lfloor \log_3 n\rfloor + 1} \delta_i(n), \end{align*}

where, letting $n = (n_\ell \ldots {n_1})_3$ denote the ternary expansion of $n$, we define $\delta_i$$\delta_i(n)$ for $i = 1, 2$$i = 0, 1, 2$ to be

\begin{align*} \delta_1 &= \begin{cases} -3 & \text{if } n \equiv 2 \pmod 3 \\ 0 & \text{else} \end{cases} \\ \delta_2 &= \begin{cases} 1 & \text{if } n \equiv 12_3 \text{ or } 22_3\pmod9\\ -1 & \text{if } n \equiv 20_3 \text{ or } 21_3\pmod9\\ 0 & \text{else} \end{cases}. \end{align*}\begin{align*} \delta_0(n) &= 9 \\ \delta_1(n) &= \begin{cases} -3 & \text{if } n \equiv 2 \pmod 3 \\ 0 & \text{else} \end{cases} \\ \delta_2(n) &= \begin{cases} 1 & \text{if } n \equiv 12_3 \text{ or } 22_3\pmod9\\ -1 & \text{if } n \equiv 20_3 \text{ or } 21_3\pmod9\\ 0 & \text{else} \end{cases}. \end{align*}

Before we define $\delta_i$ in general, let \begin{align*} (12)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell} \\ (21)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell + 1}. \end{align*} Then $(12)_3^{(i)}$ has $i$-many ternary digits and is either of the form $12...12$ or $21....12$ depending on the parity of $i$ (e.g. $(12)_3^{(2)} = 12_3$ and $(12)_3^{(3)} = 212_3$). Similarly, $(21)_3^{(i)}$ has $i$-many ternary digits and is either of the form $21...21$ or $12...21$ depending on the parity of $i$.

Then define \begin{align*} \delta_i &= \begin{cases} (-1)^{i} & \text{if } n \equiv (21)_3^{(i)} \text{ or } 3^2(21)_3^{(i-2)} + 22_3\pmod {3^i}\\ (-1)^{i+1} & \text{if } n \equiv (12)_3^{(i)} \text{ or } 3^2(12)_3^{(i-2)} + 20_3 \pmod {3^i}\\ 0 & \text{else} \end{cases} \\ \end{align*}\begin{align*} \delta_i(n) &:= \begin{cases} (-1)^{i} & \text{if } n \equiv (21)_3^{(i)} \text{ or } 3^2(21)_3^{(i-2)} + 22_3\pmod {3^i}\\ (-1)^{i+1} & \text{if } n \equiv (12)_3^{(i)} \text{ or } 3^2(12)_3^{(i-2)} + 20_3 \pmod {3^i}\\ 0 & \text{else} \end{cases} \\ \end{align*} for all $i > 2$.


Observe that this is actually equivalent to the finite state machine given by Bullet51. Plus, this gives that $\Delta_{3n} + \Delta_{3n+1} + \Delta_{3n+2} = 24$ for any $n$ since $$\delta_i(3n) + \delta_{i}(3n+1) + \delta_{i}(3n+2) = \begin{cases}27 & \text{if } i=0 \\ -3 & \text{if } i=1 \\ 0 & \text{if } i > 1\end{cases}.$$ Similarly, we can express the other finite state machines for larger $k$ in terms of $\delta_i$ with conditions modulo $k^i$.

To explain such a formula, we can examine how the $x_n$ changes $\Delta_n$. Suppose $x_n$ appears in the expression for $x_{n'}$, i.e. $x_{n'} = a + b + c$ where $x_n$ is one of $a$, $b$, or $c$. Always writing $a \leq b \leq c$ and assigning the convention that $x_n = a$ if $a \neq b$, $x_n = b$ if $a=b$ and $x_n = c$ if $b=c$, then define $$ y_n := \begin{cases} 0 & \text{if } x_n = a \\ 1 &\text{if } x_n = b \\ 2 &\text{if } x_n = c \end{cases} $$ to be the position of $x_n$ in the expression of $x_{n'}$. Then observe that $x_{n'} \equiv y_n \pmod 3$. But also observe that $y_n$ depends on $\Delta_{n-1}$ modulo $3$: $$ y_n = \begin{cases} y_{n-1} & \text{if } \Delta_{n-1} \equiv 2 \pmod 3 \\ y_{n-1} + 1 & \text{if } \Delta_{n-1} \equiv 0 \pmod 3 \\ y_{n-1} + 2 & \text{if } \Delta_{n-1} \equiv 1 \pmod 3 \end{cases}. $$ If we chase through these modular relations, we can then build the expression for $\Delta_n$ that we have above as well as the finite state machines that have been given here. This is somewhat tricky but we can start with the fact that we expect $\Delta_n$ to be $9$ if $n+1$ and $n$ are not $m'$ for some $m$ (i.e. no other $x_m$ appears in their expression as the sum of three integers), we expect it to be $6$ if no $x_m$ appears in the expression for $x_n$ but does for $x_{n+1}$ with $y_m = 0$. Then we have these corrections $\delta_i = \pm 1$ (with $i > 1$) in the other cases.


While this should work for the analogous situations with other fixed $k$, the situation becomes quite complicated for general $k$ and it is not immediately clear what a general formula would look like. Also note that if we define $A$ using $\{m \in \mathbb{Z} \mid m > \ell \}$ with $\ell \geq 0$ instead of $\mathbb{N}$, we will get something extremely similar to this.

To write the $k=3$ solution in closed form, we have \begin{align*} \Delta_n &= 9 + \sum_{i = 1}^{\lfloor \log_3 n\rfloor + 1} \delta_i, \end{align*}

where, letting $n = (n_\ell \ldots {n_1})_3$ denote the ternary expansion of $n$, we define $\delta_i$ for $i = 1, 2$ to be

\begin{align*} \delta_1 &= \begin{cases} -3 & \text{if } n \equiv 2 \pmod 3 \\ 0 & \text{else} \end{cases} \\ \delta_2 &= \begin{cases} 1 & \text{if } n \equiv 12_3 \text{ or } 22_3\pmod9\\ -1 & \text{if } n \equiv 20_3 \text{ or } 21_3\pmod9\\ 0 & \text{else} \end{cases}. \end{align*}

Before we define $\delta_i$ in general, let \begin{align*} (12)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell} \\ (21)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell + 1}. \end{align*} Then $(12)_3^{(i)}$ has $i$-many ternary digits and is either of the form $12...12$ or $21....12$ depending on the parity of $i$ (e.g. $(12)_3^{(2)} = 12_3$ and $(12)_3^{(3)} = 212_3$). Similarly, $(21)_3^{(i)}$ has $i$-many ternary digits and is either of the form $21...21$ or $12...21$ depending on the parity of $i$.

Then define \begin{align*} \delta_i &= \begin{cases} (-1)^{i} & \text{if } n \equiv (21)_3^{(i)} \text{ or } 3^2(21)_3^{(i-2)} + 22_3\pmod {3^i}\\ (-1)^{i+1} & \text{if } n \equiv (12)_3^{(i)} \text{ or } 3^2(12)_3^{(i-2)} + 20_3 \pmod {3^i}\\ 0 & \text{else} \end{cases} \\ \end{align*} for all $i > 2$.


Observe that this is actually equivalent to the finite state machine given by Bullet51. Similarly, we can express the other finite state machines for larger $k$ in terms of $\delta_i$ with conditions modulo $k^i$.

To explain such a formula, we can examine how the $x_n$ changes $\Delta_n$. Suppose $x_n$ appears in the expression for $x_{n'}$, i.e. $x_{n'} = a + b + c$ where $x_n$ is one of $a$, $b$, or $c$. Always writing $a \leq b \leq c$ and assigning the convention that $x_n = a$ if $a \neq b$, $x_n = b$ if $a=b$ and $x_n = c$ if $b=c$, then define $$ y_n := \begin{cases} 0 & \text{if } x_n = a \\ 1 &\text{if } x_n = b \\ 2 &\text{if } x_n = c \end{cases} $$ to be the position of $x_n$ in the expression of $x_{n'}$. Then observe that $x_{n'} \equiv y_n \pmod 3$. But also observe that $y_n$ depends on $\Delta_{n-1}$ modulo $3$: $$ y_n = \begin{cases} y_{n-1} & \text{if } \Delta_{n-1} \equiv 2 \pmod 3 \\ y_{n-1} + 1 & \text{if } \Delta_{n-1} \equiv 0 \pmod 3 \\ y_{n-1} + 2 & \text{if } \Delta_{n-1} \equiv 1 \pmod 3 \end{cases}. $$ If we chase through these modular relations, we can then build the expression for $\Delta_n$ that we have above as well as the finite state machines that have been given here. This is somewhat tricky but we can start with the fact that we expect $\Delta_n$ to be $9$ if $n+1$ and $n$ are not $m'$ for some $m$ (i.e. no other $x_m$ appears in their expression as the sum of three integers), we expect it to be $6$ if no $x_m$ appears in the expression for $x_n$ but does for $x_{n+1}$ with $y_m = 0$. Then we have these corrections $\delta_i = \pm 1$ (with $i > 1$) in the other cases.


While this should work for the analogous situations with other fixed $k$, the situation becomes quite complicated for general $k$ and it is not immediately clear what a general formula would look like. Also note that if we define $A$ using $\{m \in \mathbb{Z} \mid m > \ell \}$ with $\ell \geq 0$ instead of $\mathbb{N}$, we will get something extremely similar to this.

To write the $k=3$ solution in closed form, we have \begin{align*} \Delta_n &= \sum_{i = 0}^{\lfloor \log_3 n\rfloor + 1} \delta_i(n), \end{align*}

where, letting $n = (n_\ell \ldots {n_1})_3$ denote the ternary expansion of $n$, we define $\delta_i(n)$ for $i = 0, 1, 2$ to be

\begin{align*} \delta_0(n) &= 9 \\ \delta_1(n) &= \begin{cases} -3 & \text{if } n \equiv 2 \pmod 3 \\ 0 & \text{else} \end{cases} \\ \delta_2(n) &= \begin{cases} 1 & \text{if } n \equiv 12_3 \text{ or } 22_3\pmod9\\ -1 & \text{if } n \equiv 20_3 \text{ or } 21_3\pmod9\\ 0 & \text{else} \end{cases}. \end{align*}

Before we define $\delta_i$ in general, let \begin{align*} (12)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell} \\ (21)_3^{(i)} :&= \sum_{\ell=0}^{i-1} 3^\ell + \sum_{\ell=0}^{\lfloor \frac{i-1}{2} \rfloor} 3^{2\ell + 1}. \end{align*} Then $(12)_3^{(i)}$ has $i$-many ternary digits and is either of the form $12...12$ or $21....12$ depending on the parity of $i$ (e.g. $(12)_3^{(2)} = 12_3$ and $(12)_3^{(3)} = 212_3$). Similarly, $(21)_3^{(i)}$ has $i$-many ternary digits and is either of the form $21...21$ or $12...21$ depending on the parity of $i$.

Then define \begin{align*} \delta_i(n) &:= \begin{cases} (-1)^{i} & \text{if } n \equiv (21)_3^{(i)} \text{ or } 3^2(21)_3^{(i-2)} + 22_3\pmod {3^i}\\ (-1)^{i+1} & \text{if } n \equiv (12)_3^{(i)} \text{ or } 3^2(12)_3^{(i-2)} + 20_3 \pmod {3^i}\\ 0 & \text{else} \end{cases} \\ \end{align*} for all $i > 2$.


Observe that this is actually equivalent to the finite state machine given by Bullet51. Plus, this gives that $\Delta_{3n} + \Delta_{3n+1} + \Delta_{3n+2} = 24$ for any $n$ since $$\delta_i(3n) + \delta_{i}(3n+1) + \delta_{i}(3n+2) = \begin{cases}27 & \text{if } i=0 \\ -3 & \text{if } i=1 \\ 0 & \text{if } i > 1\end{cases}.$$ Similarly, we can express the other finite state machines for larger $k$ in terms of $\delta_i$ with conditions modulo $k^i$.

To explain such a formula, we can examine how the $x_n$ changes $\Delta_n$. Suppose $x_n$ appears in the expression for $x_{n'}$, i.e. $x_{n'} = a + b + c$ where $x_n$ is one of $a$, $b$, or $c$. Always writing $a \leq b \leq c$ and assigning the convention that $x_n = a$ if $a \neq b$, $x_n = b$ if $a=b$ and $x_n = c$ if $b=c$, then define $$ y_n := \begin{cases} 0 & \text{if } x_n = a \\ 1 &\text{if } x_n = b \\ 2 &\text{if } x_n = c \end{cases} $$ to be the position of $x_n$ in the expression of $x_{n'}$. Then observe that $x_{n'} \equiv y_n \pmod 3$. But also observe that $y_n$ depends on $\Delta_{n-1}$ modulo $3$: $$ y_n = \begin{cases} y_{n-1} & \text{if } \Delta_{n-1} \equiv 2 \pmod 3 \\ y_{n-1} + 1 & \text{if } \Delta_{n-1} \equiv 0 \pmod 3 \\ y_{n-1} + 2 & \text{if } \Delta_{n-1} \equiv 1 \pmod 3 \end{cases}. $$ If we chase through these modular relations, we can then build the expression for $\Delta_n$ that we have above as well as the finite state machines that have been given here. This is somewhat tricky but we can start with the fact that we expect $\Delta_n$ to be $9$ if $n+1$ and $n$ are not $m'$ for some $m$ (i.e. no other $x_m$ appears in their expression as the sum of three integers), we expect it to be $6$ if no $x_m$ appears in the expression for $x_n$ but does for $x_{n+1}$ with $y_m = 0$. Then we have these corrections $\delta_i = \pm 1$ (with $i > 1$) in the other cases.


While this should work for the analogous situations with other fixed $k$, the situation becomes quite complicated for general $k$ and it is not immediately clear what a general formula would look like. Also note that if we define $A$ using $\{m \in \mathbb{Z} \mid m > \ell \}$ with $\ell \geq 0$ instead of $\mathbb{N}$, we will get something extremely similar to this.

move horizontal line, clarify last remark
Source Link
Robin Zhang
  • 394
  • 5
  • 13
Loading
add remark about starting with {m > l} and more explanation for Delta_n expression
Source Link
Robin Zhang
  • 394
  • 5
  • 13
Loading
defined (21)_3^{(i)} and fixed error in conditions of \delta_i
Source Link
Robin Zhang
  • 394
  • 5
  • 13
Loading
Source Link
Robin Zhang
  • 394
  • 5
  • 13
Loading