6

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

2 Answers2

6

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$$

ajotatxe
  • 65,084
0

The answer by ajotatxe is only correct if you assume that the answer $z$ is real or rational. If you want integer answers $z$, then for $y = \frac{a}{b}$ rational with $gcd(a,b)=1$ the answers are

  • For smallest multiple of $y$ after $x$, the formula is $$z = a\left\lceil\frac{1+\left\lfloor\frac{b\cdot x}{a}\right\rfloor}{b}\right\rceil.$$
  • For smallest multiple of $y$ not smaller than $x$, the formula is $$z = a\left\lceil\frac{x}{a}\right\rceil.$$ Where I used the property of nested divisons for the ceiling function.

For your example $y = 0.36$, we have $a = 9$, $b = 25$ (with $gcd(9,25)=1$). Which leads to

  • the smallest multiple of $0.36$ after $3000$: $$z = 9\left\lceil\frac{1+\left\lfloor\frac{25\cdot3000}{9}\right\rfloor}{25}\right\rceil = 9\left\lceil\frac{8334}{25}\right\rceil = 9\cdot 334 = 3006,$$
  • the smallest multiple of $0.36$ not smaller than $3000$: $$z = 9\left\lceil\frac{3000}{9}\right\rceil = 9\cdot334 = 3006.$$

You can check: $3006 = 8350 \cdot 0.36$

DrAJV
  • 1