The logic behind this puzzle’s answer

puzzle

Keep a number between $1$ and $60$, including $1$ and $60$.

The aim is to find kept the number.

$1,3,5,7,9,\\
11,13,15,17,19,\\
21,23,25,27,29,\\
31,33,35,37,39,\\
41,43,45,47,49,\\
51,53,55,57,59\tag{box 1}$

$2,3,6,7,10 \\
11,14,15,18,19,\\
22,23,26,27,30,\\
31,34,35,38,39,\\
42,43,46,47,50,\\
51,54,55,58,59 \tag{box 2}$

$4,5,6,7,12,\\
12,13,14,15,20,\\
21,22,23,28,29,\\
30,31,36,37,38,\\
38,44,45,46,47,\\
52,53,54,55,60 \tag{box 3}$

$8,9,10,11,12,\\
13,14,15,24,25,\\
26,27,28,29,30,\\
31,40,41,42,43,\\
44,45,46,47,56,\\
57,58,59,60 \tag{box 4}$

$16,17,18,19,20,\\
21,22,23,24,25,\\
26,27,28,29,30,\\
31,48,49,50,51,\\
52,53,54,55,56,\\
57,58,59,60 \tag{box 5}$

$32,33,34,35,36,\\
37,38,39,40,41,\\
42,43,44,45,46,\\
47,48,49,50,51,\\
52,53,54,55,56,\\
57,58,59,60 \tag{box 6}$

Now we ask whether the number kept is in the boxes respectively.
Then we guess the number correctly with the following method in the example.

$\textbf{Example:}$ I kept $53$.

$$53\in \text{box $1$}\Rightarrow 2^{1-1}=1$$
$$53\in \text{box $3$}\Rightarrow 2^{3-1}=4$$
$$53\in \text{box $5$}\Rightarrow 2^{5-1}=16$$
$$53\in \text{box $6$}\Rightarrow 2^{6-1}=32$$
Hence, $\color{red} {1+4+16+32}=53$

Best Answer

The numbers $1$ through $60$ can be written in binary as a string of six $0$'s and $1$'s. A number is in the $n$-th box if its $n$-th digit in binary is a $1$. In your example $53$ is written $110101$ in binary because $$53=2^0+2^2+2^4+2^5=1+4+16+32,$$ and so it is in boxes $1$, $3$, $5$ and $6$.

Related Question