|
|
Mueen Nawaz wrote:
> Hi,
>
> Just found this a few days ago. It's apparently been around for years,
> so some of you may know about it:
>
> http://projecteuler.net/index.php?section=about
Coming back to it, the first one is easily done without a computer.
The sum of the numbers in any range that are divisible by 3 or 5 is
equal to the sum of the numbers that are divisible by three, plus the
sum of the numbers that are divisible by five, minus the sum of the
numbers that are divisible by 15.
Our given range is from 1 to 999, so:
(3+999)*333/2 + (5+995)*(199)/2 - (15+990)*66/2 = 233168.
I used a calculator for the multiplying and adding here.
Regards,
John
Post a reply to this message
|
|