Find smallest number bigger than y that is multiple of x

4.9k Views Asked by At

I can't seem to find an answer for this, as all the topics regarding multiples deal with integers...

I need to find the smallest number after x that is multiple of 0.36.

For example if x = 3000, what would be the number closest to 3000 that is multiple of 0.36?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

The floor and the ceil function are very handy in this kind of problems:

  • Floor: $\lfloor x\rfloor$ is the greatest integer that is not greater than $x$.
  • Ceil: $\lceil x \rceil$ is the least integer that is not lesser than $x$.

Now, I will answer your question: the multiple of $0.36$ after $x$ is $$\left ( \left\lfloor\frac{x}{0.36}\right\rfloor +1 \right)\cdot 0.36$$

But if you want the smallest multiple of $0.36$ that is not smaller than $x$, then the formula is

$$\left\lceil\frac{x}{0.36} \right\rceil\cdot 0.36$$