P.E.1.: Multiples of 3 or 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.

2 solutions

Swapnil Bhargava
Sep 21, 2014

Arvind has given the solution using code.We can also find the answer without writing a program.The numbers which are multiples of 3 and below 1000 are numbers in the sequence 3,6,9,......999 which turns out to be an AP whose sum comes out to be 166833.The numbers which are multiples of 5 and below 1000 are numbers in the sequence 5,10,15,......995 which again turns out to be an AP whose sum comes out to be 99500.It seems the answer should be 166833+99500=266333.But there is a problem both the sequences include numbers which are multiple of both 3 and 5.Such numbers are hence counted twice.So, to get the answer we find the sum of the sequence 15,30,45,.....990 which comes out to be 33165 and subtract it from 266333 to get 233168 as the final result.

Thats a really nice solution there! Its always good to know both ways of solving. Kudos!

Arvind Srinivasan - 6 years, 8 months ago
Arvind Srinivasan
Sep 18, 2014

My python code goes as follows:

  print 'Following is the sum of all mutliples of 3 or 5 below 1000:'
  sum=0
  for i in range(1,1000):
          if i % 3 == 0 or i % 5 == 0:
               sum=sum+i
  print sum

It works by checking divisibility and adding it to the initial sum (0). It repeats this action upto the number 999 (1000 is exclusive according to question).

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...