# Puzzling function

Let $$f$$ be a function whose domain is the set of positive integers, and for positive integers $$a$$, $$b$$ and $$n$$, if $$a + b = 2^{n}$$, then $$f(a) + f(b) = n^2$$. What is $$f(2021)$$?

I started by testing values for $$a$$, $$b$$ and $$n$$, with the hope of finding a pattern, but so far I can't say I've made any headway;

For $$a=b=n=1,\ f(1)+f(1)=2^1, so f(1)=\frac{1^2}{2}=\frac12$$

I realize that it becomes easier to find $$f(a)$$ if $$a$$=$$b$$

So $$a = b = 2^{n-1}$$ then $$f(a) = \frac{n^2}{2}$$ that is, $$f(2^{n-1}) = \frac{n^2}{2}$$

At this point, I cannot see where to move forward.

• Please edit to include your efforts. A natural starting point might be to find $f(k)$ for small values of $k$.
– lulu
Jun 24 at 16:38
• Note: may be worth remarking that $f(k)$ doesn't seem to be an integer for some small $k$. Nothing wrong with that, I suppose, but is it what you intended?
– lulu
Jun 24 at 16:41
• please include you efforts Jun 24 at 16:58
• In your $a=b=n=1$ example, I think you mean: $1+1=2 = 2^1$, so $f(1) + f(1) = 1^2 = 1$ and thus $f(1) = 0.5$. Jun 24 at 17:15
• Note that $2021+27=2048=2^{11}$ thus you can obtain $f(2021)$ in terms of $f(27)$. Repeat the process till you get a known value Jun 24 at 17:24

A nearby power of $$2$$ to $$2021$$ is $$2048=2^{11}$$. So you know that $$f(2021)+f(27)=11^2$$ since $$2021+27=2048$$. Great, but now we need to know $$f(27).$$ Well, a nearby power of $$2$$ to $$27$$ is $$32=2^5.$$ So then because $$27+5=32$$, we know that $$f(27)+f(5)=5^2$$. Continue in this way until you get down to some small powers of $$2$$, which you can directly compute. Hope this helps.
• $2021+27=2048$, but $2021+37=2058$.
• Sorry, just seeing this request now. We would next need to find $f(5)$. For this, note that $5+3=8=2^3$, so $f(5)+f(3)=3^2=9$. Now we need $f(3)$, so we use $3+1=2^2$, so $f(3)+f(1)=2^2=4$. A comment by rogerl points out that $f(1)=.5$. Now you can back solve all the way up to $f(2021)$. Jun 28 at 16:37