Sum of Multiples in Interval

<p><span style="font-size:22px"><a href="https://www.prepswift.com/quizzes/quiz/prepswift-sum-of-multiples-in-interval" target="_blank">Sum of Multiples in Interval Exercise</a></span></p><p>The best way to illustrate how to find the <strong><span style="color:#27ae60;">Sum of Multiples in an Interval</span></strong> is with an example. Imagine we want to find the sum of all multiples of $3$ from $1$ to $500$. Follow these steps:</p> <ul> <li><strong><span style="color:#e74c3c;">Step 1</span></strong>: Find the number of multiples of $3$ from $1$ to $500$. <ul> <li>$\frac{500}{3}$, take the whole number result, to get 166. Put this number aside for now.</li> </ul> </li> <li><strong><span style="color:#e74c3c;">Step 2</span></strong>: List out the first three multiples and last three multiples in the interval. <ul> <li>$3$, $6$, $9$...$492$, $495$, $498$</li> </ul> </li> <li><strong><span style="color:#e74c3c;">Step 3</span></strong>: Notice that every &quot;pair&quot; in that list above adds up to $501$. <ul> <li>$3+498=501$</li> <li>$6+495=501$</li> <li>$9+492=501$</li> </ul> </li> <li><strong><span style="color:#e74c3c;">Step 4</span></strong>: We know that every &quot;pair&quot; in the list adds up to $501$. We also know that we have a total of $166$ multiples of $3$ (from step 1), giving us $83$ pairs ($\frac{166}{2}$). &nbsp;We can then find the total sum by multiplying these two numbers together (see below):</li> </ul> <p>$$\frac{166}{2} \times 501 = 41,583$$</p> <p>Pretty frickin&#39; cool if I must say so myself.</p> <p><strong>NOTE:&nbsp;</strong>This trick still works even if you find an odd number of multiples in an interval. For example, there are $9$ multiples of $3$ from $1$ to $28$ and each pair adds up to $30$. To find the sum of all multiples, see below:</p> <p>$$\frac{9}{2} \times 30=135$$</p>