Multiples of 3 and 5

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.


The answer is 233168.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Hasmik Garyaka
Sep 17, 2017

sum([i for i in range(1000) if i%3==0 or i%5==0])

Anubhav Sharma
Mar 20, 2015

Here, is QBASIC Programming Code

CLS

S = 0

FOR A= 1 TO 999

IF A MOD 3 = 0 OR A MOD 5 = 0 THEN S = S + A

NEXT A

PRINT S

END

Nafees Zakir
Oct 3, 2014
1
2
3
4
5
6
7
8
>>> n =0
>>> for x in range(0,1000):
    if(x%3==0 or x%5==0):
        n= n+x


>>> print n
>>> 233168

Ans = 233168 \boxed{233168}

Rajeev Sebastian
Jul 31, 2014

sum of multiples of 3 is added to sum of multiples of 5. Sum of multiples of 15 is subtracted from the previous sum

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...