Combining sum of floor functions

650 Views Asked by At

Consider a simple sum of floor functions: $$S = c\left\lfloor \frac{x}{a}\right\rfloor + d\left\lfloor \frac{x}{b} \right\rfloor$$

Can we combine these two terms into a single function? I am trying to simplify something like this to avoid successive divisions in a computer program.

My question, in general, is: can we combine the following $k$ terms to avoid performing $k$ divisions and multiplications of $x$: $$S(x,k)=\sum_{i=0}^{k}c_i\left\lfloor \frac{x}{a_i}\right\rfloor$$

1

There are 1 best solutions below

6
On

A simple compute, this might not be a proof :

Assume $\exists a, b \in \Bbb N $ s.t. $\forall x$

$$\left[\frac{x}{2}\right] + \left[\frac{x}{3}\right] = a\left[\frac{x}{b}\right]$$

put x = 2 :

$$a\left[\frac{2}{b}\right] = 1$$

$$\Rightarrow a = 1, b = 2$$

But $\left[\frac{x}{2}\right] + \left[\frac{x}{3}\right] > \left[\frac{x}{2}\right]$ for large enough $x$.

This form might not be able to simplify if the denominators has no limitation.