Let $n$ be some fixed, odd integer and $ q_k = 2^{\lceil \log_2(3^{k}n) \rceil} - 3^{k}n $ be the difference between $3^kn$ and the smallest power of two $\geq 3^kn$ .
Now the following two things seem to hold
a) $q_k \lt q_{k+1}$ implies $ q_{k+1}-3\cdot q_{k} = 2^{\lceil \log_2(3^{k}n) \rceil}$, or written out: $$ (2^{\lceil \log_2(3^{k+1}n) \rceil} - 3^{k+1}n) - 3 \cdot (2^{\lceil \log_2(3^{k}n) \rceil} - 3^{k}n) = 2^{\lceil \log_2(3^{k}n) \rceil} $$
b) $q_k \gt q_{k+1}$ implies $ q_{k+2} = 6q_{k} + q_{k+1} $, or written out: $$ 2^{\lceil \log_2(3^{k+2}n) \rceil} - 3^{k+2}n = 6 \cdot (2^{\lceil \log_2(3^{k}n) \rceil} - 3^{k}n) + 2^{\lceil \log_2(3^{k+1}n) \rceil} - 3^{k+1}n$$
My questions are
- Is there any trivial explanation for that? I could imagine that both follow somehow from factoring but I cant quite wrap my head around it because of the $\lceil \dots \rceil$
- Is there anything we can say about $q_{k+2}$ when $q_k \lt q_{k+1}$?
Example for a): Let $n = 17$, then $q_1= 13, q_2 = 103 $ and $ 103 - 3\cdot 13 = 2^{\lceil \log_2(3\cdot 13) \rceil}$
Example for b): Let $n=15$, then $q_2=121, q_3=107, q_4=833 $ and $ 833 = 6 \cdot 121 - 107$