Prove that there are infinitely many positive integers $n$ such that $n^2$ written in base $4$ contains only digits $1$ and $2$.
Problem
Source: 2021 MEMO T-8
Tags: number theory, Digits, Perfect Squares, memo, MEMO 2021
08.01.2022 15:45
Any solution...?
09.01.2022 22:08
2021 MEMO T-8 wrote: Prove that there are infinitely many positive integers $n$ such that $n^2$ written in base $4$ contains only digits $1$ and $2$. We'll prove a stronger statement: Stronger Problem wrote: Prove that there are infinitely many positive integer $n$ such that the base $4$ representation of $n^2$ contains only digits $1$ and $2$, and starts with digit $1$. We'll construct such number inductively. First of all, $5^2 = (121)_4$ satisfies the problem's condition. Now, let us suppose that we have a number $A$ that satisfies the problem's condition. We'll construct a larger number that satisfies the problem's condition. Let $\ell \in \mathbb{N}$ be the smallest positive integer such that $A < 4^{\ell}$. We'll prove that $(2^{2 \ell - 1} + 1)^2 \cdot A$ satisfies the problem's condition. First of all, since $A$ is a perfect square, then $(2^{2 \ell - 1} + 1)^2 \cdot A$ is also a perfect square. Write $A$ in its base $4$ representation, i.e. \[ A = a_{\ell - 1} \cdot 4^{\ell - 1} + a_{\ell - 2} \cdot 4^{\ell - 2} + \dots + a_1 \cdot 4^1 + a_0 \cdot 4^0 \]By assumption, $a_i \in \{ 1, 2 \}$ for all $1 \le i \le \ell - 2$ and $a_i = 1$ for $i = 0, \ell - 1$. Therefore, \begin{align*} (2^{2 \ell - 1} + 1)^2 \cdot A &= (4^{2 \ell - 1} + 4^{\ell} + 1) \cdot A \\ &= (4^{2 \ell - 1} + 4^{\ell} + 1) \cdot \sum_{i = 0}^{\ell - 1} a_i \cdot 4^i \\ &= \sum_{i = 1}^{\ell - 1} a_i \cdot 4^{i + 2 \ell - 1} + (a_0 + a_{\ell - 1}) \cdot 4^{2 \ell - 1} + \sum_{j = 0}^{\ell - 2} a_j \cdot 4^{j + \ell} + \sum_{k = 0}^{\ell - 1} a_k \cdot 4^k \\ &= \sum_{i = 0}^{3 \ell - 2} b_i \cdot 4^{i} \end{align*}where we define \begin{align*} b_i = \begin{cases} a_i &\ \text{if } 0 \le i \le \ell - 1 \\ a_{i - \ell} &\ \text{if } \ell \le i \le 2 \ell - 2 \\ 2 &\ \text{if } i = 2 \ell - 1 \\ a_{i - 2 \ell + 1} &\ \text{if } 2 \ell \le i \le 3 \ell - 3 \\ 1 &\ \text{if } i = 3 \ell - 2 \end{cases} \end{align*}This satisfies our problem's condition. Therefore, we are done. Motivational Remark. In such construction problem, there are normally three ways you could do to approach this: explicitly provide a construction, create construction iteratively, or proving the existence of such numbers. The best strategy to use here is to create construction iteratively, i.e. suppose I have a number $x_i$ with such property, can I construct another number involving $x_i$ with such property? We would like to somehow use the form $x_i$ we have now to construct a larger number, the best way to do this is to "concatenate" this number with another number so that it forms a perfect square. This motivates us to multiply $x_i$ by a number of the form $(2^j + 1)^2 = 4^j + 2^{j + 1} + 1$ for some $j$, as in modulo $4$, we could force the base $4$ representation of $x_i$ to appear a bunch of times. The main problem now is that we have to force this number to explicitly contain only $1$ and $2$. Since we're working with base $4$, it's better for $2^{j + 1}$ to be a power of $4$ as well. Let $b_4(x_i)$ denote the base $4$ representation of $x_i$. We would have something like: \[ (2^{2\ell - 1} + 1)^2 \cdot x_i = (4^{2\ell - 1} + 4^{\ell} + 1) \cdot x_i \]which has base $4$ representation of \[ \begin{matrix} 4^{2 \ell - 1} \cdot x_i = &b_4(x_i) &\underbrace{0 \cdots 0}_{\ell - 1\ \text{zeroes}} &\underbrace{0 \cdots 0}_{\ell \ \text{zeroes}} \\ 4^{\ell} \cdot x_i = & &b_4(x_i) &\underbrace{0 \cdots 0}_{\ell \ \text{zeroes}} \\ x_i = & & &b_4(x_i) \end{matrix} \]The main problem here is that we know $b_4(x_i)$ contains only $1$ and $2$, and suppose it has $r$ number of digits. Note that if $r \le \ell - 1$, then the last $\ell - 1$ digits of the representation contain a zero. So it makes sense that we have $r \ge \ell$. What happens when $r = \ell$, this means that the first digit of $b_4(x_i)$ and the last digit of $b_4(x_i)$ is added up because they're being used at the same place in the base $4$ representation (because there is only $\ell - 1$ zeroes in the "middle part" of the dissection above). Therefore, since we know that $i^2 \not \equiv 2 \pmod{4}$, i.e. the last digit of $b_4(x_i)$ has to be $1$; it suffices to force the first digit of $b_4(x_i)$ to be one. This approach flows well even inductively, because the new number we constructed has the first digit being the same as first digit of $b_4(x_i)$, which is still 1. Therefore, we are done. It suffices to find one such number, $5^2 = (121)_4$ works.
10.01.2022 16:43
$$x=(2^{2k-1}+1)n$$if the same condition is satisfied for $n$, the same condition is satisfied for $x$.$k$ is the number of digits in the numerical system of $n$ $4$.