Wednesday, September 28, 2011

Math Problem

One of the mathematical problems that I’ve seen today and decided to solve it :)
Problem:
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.

Solution (This is my own solution – you can solve it using another way)
-The nearest multiple of 3 below to 1000 is 999 then we have 999/3 = 333 multipliers –>1 –> “m”
-The nearest multiple of 5 below to 1000 is 995 then we have 995/5 = 199 multipliers –>2
--> from step “1” we have:
The sum of all multiples of a Number n = (the number in the set “n”) x (The mean of the Set “o”)
n = 3 ,  o = m(m + 1) / 2 = 333(333 + 1)/2 = 333 (334)/2 = 55611

then the sum = 3 * 55611 = 166833 –> 3
--> from step “2” we have:
n = 5, o = 199 (200) / 2 = 19900
then the sum = 5 * 19900 = 99500 –> 4
From step “3” and step “4” we have:
the total sum of all multiplies of 3 and not or 5 below 1000 = 166833 + 99500 = 266333
We want now to remove the common multipliers between the 3 and 5 –> 3 * 5 = 15 –> n = 15
-The nearest multiple of 15 below to 1000 is 990 then we have 990/15 = 66 multipliers
then the sum = 15 * 66(67)/2 = 33165

Finally we got, the total sum of all multiples of 3 or 5 below 1000 = 266333 – 33165 = 233168

hope you enjoyed it too;
Thanks;
Mohamed Adel
For More Info Please Visit: http://projecteuler.net

No comments:

Post a Comment

Search This Blog