Problem 860: (2021 AIME II, 15)
Let $f(n)$ and $g(n)$ be functions satisfying \[ f(n) = \begin{cases} \sqrt{n} & \text{ if } \sqrt{n} \text{ is an integer}\\ 1 + f(n+1) & \text{ otherwise} \end{cases} \] and \[ g(n) = \begin{cases}\sqrt{n} & \text{ if } \sqrt{n} \text{ is an integer}\\ 2 + g(n+2) & \text{ otherwise} \end{cases} \] for positive integers $n$. Find the least positive integer $n$ such that $\tfrac{f(n)}{g(n)} = \tfrac{4}{7}$.
- Let $k^2$ be the least square $\ge n$ and $d=k^2-n$. Then $f(n)=k+d$. If $d$ is even, $g(n)=f(n)$; if $d$ is odd, $g$ goes on to $(k+1)^2$, and then $g(n)=k+1+(2k+1+d)=3k+2+d$.
- $\frac{f}{g}=\frac47$ needs $d$ odd and $7(k+d)=4(3k+2+d)$, i.e.\ $3d=5k+8$. Also $d\le2k-2$, so $k\ge14$.
- $k=14$ gives $d=26$ (even). $k=17$ gives $d=31$, odd. So $n=289-31=258$. The answer is $\boxed{258}$.
Let $f(n)$ and $g(n)$ be functions satisfying \[ f(n) = \begin{cases} \sqrt{n} & \text{ if } \sqrt{n} \text{ is an integer}\\ 1 + f(n+1) & \text{ otherwise} \end{cases} \] and \[ g(n) = \begin{cases}\sqrt{n} & \text{ if } \sqrt{n} \text{ is an integer}\\ 2 + g(n+2) & \text{ otherwise} \end{cases} \] for positive integers $n$. Find the least positive integer $n$ such that $\tfrac{f(n)}{g(n)} = \tfrac{5}{9}$.