Is it possible to simplify $(x \pmod a) - (x \pmod b)$?

54 Views Asked by At

I have an equation that looks like:

$$\frac{(x \pmod a) - (x \pmod b)}{b}$$

is there any way to simplify this further?

1

There are 1 best solutions below

0
On

Well, using $a \pmod{b}=a-b\lfloor\frac{a}{b}\rfloor$, we can simplify it to $$\frac{1}{b}\left(b\left\lfloor\frac{x}{b}\right\rfloor-a\left\lfloor\frac{x}{a}\right\rfloor\right)$$ See if you can simplify it further by investigating the floor function.