school assignment

hello i need help on this question "If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000."
i am really crop in the for loop. i really need help.
Use modulus(%) to check for remainders in your loop iterating from 1 to 1000. For example (pseudo code):

1
2
3
4
loop {
   if i % 3 = 0 then sum += i;
   if i % 5 = 0 then sum += i;
} i++


That should get you started. Do you have any code so far?



no i don't, tanks this really should help me , but u can still help me out in total cos am over exhausted and i need to submit it tomorrow
Just translate the pseudo-code above to C++ syntax and spit out the value of sum at the end. I unknowingly did most of it for you already.
yeah i got it all tanks so much
Topic archived. No new replies allowed.