By virtue of the accepted answer in your linked question, you can take the nearest integer function of $\sqrt x$ and square it. However it may not be obvious (or seemingly too obvious to be true) so here are more details:
The nearest integer function (for $x \notin \{k+\frac12| k \in \mathbb Z\}$ to avoid ambiguities) is equal to $\left\lfloor x + \frac12\right\rfloor$. Fortunately for the square root, it is never an integer plus half. Hence we can also write
$$f(x) = \left\lfloor \sqrt x + \frac12\right\rfloor^2$$
To prove that this formula works, we consider the cases (where $n \in \mathbb N \cup \{0\}$):
Case 1: $n^2 \le x \le n^2+n < (n+\frac12)^2$
Case 2: $(n+\frac12)^2< n^2+n+1 \le x < (n+1)^2$
and we see that both cases work perfectly fine, given that $x$ is a positive integer.