The trick to answering this question is to think about how you would do it with pen and paper (and a calculator) and put that process into mathematical notation that does that job. To begin in the manual process, you may start at the beginning number and ask what is the first number that is divisible by #3#?
#100 divide 3 = color(red)33.333...# not divisible by #3#
#101 divide 3 = color(red)33.666...# not divisible by #3#
#102 divide 3 = color(blue)34# divisible by #3#
then, we may wonder where would we stop adding? Working backwards from #500#, we do the same:
#500 divide 3 = color(red)166.666...# not divisible by #3#
#499 divide 3 = color(red)166.333...# not divisible by #3#
#498 divide 3 = color(blue)166# divisible by #3#
So we now know that we need to add the numbers from #102# to #498# counting by #3#'s.
#T = sum_(i=133,136,139,...)^498 i #
Each of these numbers is divisible by #3# so we know we can factor out a #3# from each of them. If we let #j=3i# we get:
#T= sum_(j=34)^166 3j = 3sum_(j=34)^166 j#
We can simplify this sum further by noting that we start at #j=34# whereas it's normal to start at #1#. We can fix this by letting #j=k+33#:
#T= 3sum_(k=1)^133 (k+33) = 3sum_(k=1)^133 k + 3sum_(k=1)^133 33#
The second of the two sums on the right is simply the number #33# added to itself #133# times and then multiplied by #3# which is #3*133*33 = 13167#.
#T = 3sum_(k=1)^133 k + 13167#
Finally we have the well known sum of the first #n# integers,
#sum^n i = 1/2 n(n+1)#
Some simple proofs of this can be found here
#T = 3* 1/2 *133*134 + 13167 = 39900#
I also like to write a quick little program to check my work:
#color(green)tt("% The sum of all integers between 100 and 500")#
#color(green)tt("% that are divisible by 3?")#
#tt("total =0;")#
#color(blue)tt("for ")##tt("i = 100:500")#
#color(blue)tt(" if ")##tt("mod(i,3) == 0 ")#
#tt(" total = total + i;")#
#color(blue)tt(" end")#
#color(blue)tt("end")#
#tt(">> total")#
#tt("total =")#
#tt(" 39900")#