Problem

Source: 2024 Taiwan TST Round 2 Independent Study 2-N

Tags: Taiwan, number theory



For any positive integer $n$, consider its binary representation. Denote by $f(n)$ the number we get after removing all the $0$'s in its binary representation, and $g(n)$ the number of $1$'s in the binary representation. For example, $f(19) = 7$ and $g(19) = 3.$ Find all positive integers $n$ that satisfy $$n = f(n)^{g(n)}.$$ Proposed by usjl