Show $ \left\lfloor\frac{2n}{p} \right\rfloor - 2 \left\lfloor \frac{n}{p} \right\rfloor \in \{ 0, 1 \}$

102 Views Asked by At

I conjecture that $$ \left\lfloor\frac{2n}{p} \right\rfloor - 2 \left\lfloor \frac{n}{p} \right\rfloor \in \{ 0, 1 \}. $$ I know that it is always nonnegative, and equals $1$ for $n < p \le 2n$, but the general case for $n$ a natural number and $p$ prime is missing. Any hints?

1

There are 1 best solutions below

0
On BEST ANSWER

By denoting with $\{x\}$ the fractional part of $x$, i.e. $x-\lfloor x\rfloor$, we have: $$ f_p(n)=\left\lfloor\frac{2n}{p} \right\rfloor - 2 \left\lfloor \frac{n}{p} \right\rfloor = \left\{\frac{2n}{p}\right\}-2\left\{\frac{n}{p}\right\}$$ where the RHS is trivially a periodic function with period $p$, so $f_p$ just detects if $n\pmod{p}$ is $>\frac{p}{2}$ or not.