Solution

Considering only the integers from \(1\) to \(1000\) inclusive, find the sum of those integers which are either multiples of \(5\) (i.e., \(5\), \(10\), \(15\), …) or multiples of \(8\) (i.e., \(8\), \(16\), \(24\), …) but are not multiples of both \(5\) and \(8\).

We need \((5 + 10 + 15 \ldots + 1000) + (8+16+24+\ldots +1000) - 2(40 + 80 + \ldots + 1000).\)

We’ll use the formula that the sum of the first \(n\) terms of an arithmetic progression is \[\dfrac{n}{2}(u_1 + u_n),\]

where \(u_n\) is the \(n\)th term. So here we have

\[\dfrac{200}{2}(5+1000) + \dfrac{125}{2}(8+1000)- 2\times \dfrac{25}{2}(40+1000) = 137 500.\]

Alternatively, we have

\[(5 + 10 + 15 \ldots + 1000) + (8+16+24+\ldots +1000) - 2(40 + 80 + \ldots + 1000) \]

\[= 5(1+2+3\ldots+200) + 8(1+2+3+\ldots+125) - 2\times 40(1+2+3+\ldots + 25).\]

Now we know \(1 + 2 + \ldots + n = \dfrac{n(n+1)}{2}\), so this becomes

\[5\dfrac{200(201)}{2}+8\dfrac{125(126)}{2}-80\dfrac{25(26)}{2} = 137 500.\]