I think you can solve it in constant time on paper (or with one expression in your programming language), no need for loops
For 3 and 5, yeah, you can for any bound [eqn]n[/eqn] (inclusive, use [eqn]n - 1[/eqn] if you don't want to include it), it's just:
[eqn]\displaystyle \left ( \sum_{k = 1}^{\lfloor n / 3 \rfloor} 3k \right ) + \left ( \sum_{k = 1}^{\lfloor n / 5 \rfloor} 5k \right ) - \left ( \sum_{k = 1}^{\lfloor n / 15 \rfloor} 15k \right )[/eqn]
Which simplifies down to (the floor symbols indicate integer division):
[eqn]\displaystyle \frac{3}{2} \left \lfloor \frac{n}{3} \right \rfloor \left (\left \lfloor \frac{n}{3} \right \rfloor + 1 \right ) + \frac{5}{2} \left \lfloor \frac{n}{5} \right \rfloor \left (\left \lfloor \frac{n}{5} \right \rfloor + 1 \right ) - \frac{15}{2} \left \lfloor \frac{n}{15} \right \rfloor \left (\left \lfloor \frac{n}{15} \right \rfloor + 1 \right )[/eqn]
For [eqn]n = 1000[/eqn], this gives [eqn]234168[/eqn]. For [eqn]n = 999[/eqn], we get [eqn]233168[/eqn] as expected.
You can see the general pattern - sum up the multiples of each number required (here 3 and 5), and then subtract any numbers which are multiples of any two of them at the same time. You can generalize this to more than two numbers, but it gets pretty messy as you need [eqn]2^p - 1[/eqn] individual sums to get the correct result for [eqn]p[/eqn] different numbers, so it gets impractical if you need to consider many different divisors.