Multiples of three and five below n

138 Views Asked by At

I am tackling a problem which asks:

Find the sum of all the multiples of 3 or 5 below 1000.

My reasoning is that since Since $\left\lfloor\frac{1000}{3}\right\rfloor = 333$ and $\left\lfloor\frac{1000}{5}\right\rfloor = 200$

This sum can be denoted as: \begin{equation} \sum\limits_{n=1}^{333}3n + \sum\limits_{m=1}^{200} 5m = 3\sum\limits_{n=1}^{333}n + 5\sum\limits_{m=1}^{200} m \end{equation} Using the identity $$ \sum\limits_{i=1}^{n} i = \frac{n(n+1)}{2} $$ It can be solved analytically as $$ 3\sum\limits_{n=1}^{333}n + 5\sum\limits_{m=1}^{200} m = \frac{3}{2}(333(333+1)) + \frac{5}{2}(200(200+1)) = 267333 $$

But apparently this is incorrect? Where did I go wrong in my reasoning?

Edit

I tried to correct the double multiples with: $$3\sum\limits_{i=1}^{333}i + 5\sum\limits_{j=1}^{200}j - 15\sum\limits_{k=1}^{66} k = 234168$$

But this seems to be wrong as well...

Edit 2:

GOT IT!

Up to and not including.

$$3\sum\limits_{i=1}^{333}i + 5\sum\limits_{j=1}^{199}j - 15\sum\limits_{k=1}^{66} k = 233168$$

Or, more ugly: $$3\sum\limits_{i=1}^{\left\lfloor\frac{999}{3}\right\rfloor}i + 5\sum\limits_{j=1}^{\left\lfloor\frac{999}{5}\right\rfloor}j - 15\sum\limits_{k=1}^{\left\lfloor\frac{999}{3\cdot 5}\right\rfloor} k = 233168$$

2

There are 2 best solutions below

2
On BEST ANSWER

Some numbers, such as $15$ and $30$, are multiples of both $3$ and $5$. These should be counted only once.

Edit: After comments to the question (not to this answer), I see that another issue is that you include $1000$ as the last term, but $1000$ is not below $1000$.

0
On

you double added all the multiples of 15