2021 AIME II Problem 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 \frac{f(n)}{g(n)}=\frac{4}{7}.