If for an integer $n$, $\frac{f_1(n)}{f_2(n)}=\frac 47$, then $n$ is?

Consider two functions $f_1(x)$ and $f_2(x)$ satisfying $$f_1(x)= \left\{ \begin{array}{ll} \sqrt{x} &; \sqrt{x}\in\mathbb{Z} \\ 1+f_1(x+1) &; \text{otherwise} \\ \end{array} \right. $$ and $$f_2(x)= \left\{ \begin{array}{ll} \sqrt{x} &; \sqrt{x}\in\mathbb{Z} \\ 2+f_2(x+1) &; \text{otherwise} \\ \end{array} \right. $$ If for an integer $n$, $\frac{f_1(n)}{f_2(n)}=\frac 47$, then $n$ is ?

A. $2$

B. $16$

C. $258$

D. $129$

My attempt:

Let $n=k^2-m$, where $m$ is the difference between $n$ and the next perfect square number.

So, $$f_1(n)=(1\times m)+k=m+k$$ and $$f_2(n)=(2\times m)+k=2m+k$$

$$\Rightarrow \frac{f_1(n)}{f_2(n)}=\frac{m+k}{2m+k}=\frac 47$$ $$\Rightarrow m=3k$$

$\Rightarrow n=k^2-3k$

However, I am unable to obtain an integral solution for $k$ from either of the options.

The given answer is

C. $258$

Can someone point out my mistake or suggest an alternate method?


I was pretty stumped by this initially too, so I worked on it. Then I realised something: $$(k-1)^2<k^2-m\leq k^2$$ and it is hence worth noting that $$m<2k+1$$ For any $k \geq 1$, $$3k \geq 2k+1$$ meaning that $3k$ is an impossible value for $m$ to take.

I wasn't initially convinced by this, so I went to Desmos to try it myself. This is what I got: Desmos Plot

Surprisingly, the math DOES work out. So it seems that there is no solution.

Something I noticed in addition is that there seems to be the case that the minimum value for each "branch" seems to approach $\frac{3}{5}$, which I have not proved. But yeah, this was a pretty interesting exploration for me.

Edit: Brian Moehring in the comments explained why the $\frac{3}{5}$ arises. I'll put what they said here for easy reference and to explain the full story in one message:

To show the lower limit of $\frac{3}{5}$, note instead that $m<2k−1$ and setting $m=2k$ gives a lower bound of exactly $\frac{3}{5}$ (with $m=2k−2$ approaching). There's also a value of $\frac{1}{2}$ when $n<0$.