Q1. Find the sum of all integers between 200 and 400 that are divisible by 6.
I've never properly studied this topic before, but I'll attempt the first question for you:
Divisible by 6 = {204, 210, 216, 222, ..., 396}
We know that the sum of integers from 1 to n is n(n + 1) / 2
We also know that the sum of integers from 1 to m is m(m + 1) / 2
Thus we know that the sum of integers from m to n is n(n + 1) / 2 - m(m + 1) / 2 (+m)
(The (+m) on the end is if we want to include m)
If we want to go in steps of 2, we can just double the sum:
Sum from 2 to 10 in steps of 2 = 2 * sum from 1 to 5 in steps of 1
So 2 + 4 + 6 + 8 + 10 = 2*5*6/2 = 30
Sum from 6 to 30 in steps of 6 = 6 * sum from 1 to 5 in steps of 1
So 6 + 12 + 18 + 24 + 30 = 6*5*6/2 = 90
Sum from 36 to 60 in steps of 6 = 6 * sum from 6 to 10 in steps of 1
= 6 * (sum from 1 to 10 in steps of 1 - sum from 1 to 5 in steps of 1)
So 36 + 42 + 48 + 54 + 60 = 6 * (10*11/2 - 5*6/2) = 3*(110 - 30) = 3*80 = 240
Now that we have figured all of that out, we are ready for our question:
204 / 6 = 34
396 / 6 = 66
So the sum of all integers between 200 and 400 that are divisible by 6:
= sum from 204 to 396 in steps of 6
= 6 * sum from 34 to 66 in steps of 1
= 6 * (sum from 1 to 66 in steps of 1 - sum from 1 to 33 in steps of 1)
= 6 * (66*67/2 - 33*34/2)
= 3 * (66*67 - 33*34)
= 99 * (2*67 - 34)
= 99 * (134 - 34)
= 99 * 100
= 9900