Is roundDown(roundDown(x/n)/n) = roundDown(x/n²)?

32 Views Asked by At

It somehow feels wrong, but I can't find an example for it being wrong.

n and x are positive integers.

1

There are 1 best solutions below

2
On

If you write $x$ in base $n$ you have $x=x_k \dots x_2 x_1 x_0$ where each digit $x_i$ belongs to $\{ 0,1,\dots,n-1 \}$.

Take $a=x_k\dots x_2$, $b=x_1$ and $c=x_0$; this means that $$x=an^2+bn+c$$ with $0 \le a$, $0 \le b < n$ and $0 \le c < n$.

Now we can compute $$\frac{x}{n} = an + b + \frac{c}{n}$$ which rounds down to $an+b$.

Do you think you can continue the reasoning from there, and find the left-hand side and right-hand side of your formula in terms of $a$, $b$, $c$?