Problem

Source: SMMC 2024 A2

Tags: number theory



A positive integer $n$ is tripariable if it is possible to partition the set $\{1, 2, \dots, n\}$ into disjoint pairs such that the sum of two elements in each pair is a power of $3$. For example $6$ is tripariable because $\{1, 2, \dots, n\}=\{1,2\}\cup\{3,6\}\cup\{4,5\}$ and $$1+2=3^1,\quad 3+6 = 3^2\quad\text{and}\quad4+5=3^2$$are all powers of 3. How many positive integers less than or equal to 2024 are tripariable?