You are viewing a single comment's thread from:

RE: Brainsteem Compute #1 Prize Computational Maths Puzzle [Win 40% and 10% in SBD]

in #mathematics7 years ago

I'd like to give this a shot. beriberi's methodology is accurate but as they mentioned something was missing.

The sum of all positive integers from 1 to x is computed as x*(x+1)/2. This is the key component.

The multiples of 5 under 2000 go from 5 to 1995. Factoring out 5 yields 5*(1+2+...+399).
5 * [399 * 400 / 2] = 5 * 79800 = 399,000

The multiples of 7 under 2000 go from 7 to 1995. Factoring out 7 yields 7*(1+2+...+285).
7 * [285 * 286 / 2] = 7 * 40755 = 285,285

Multiples of 35 have thus been double-counted and need to be subtracted. Those go from 35 to 1995. Factoring out 35 yields 35*(1+2+...+57).
35 * [57 * 58 / 2] = 35 * 1653 = 57,855

The sum then is 399,000 + 285,285 - 57,855 = 626,430

Sort:  

same answer here with one small difference in the calculation:
To find for example the multiples of 5 below 2000, we notice the first is 5 and the last is 1995 and there are 399 such numbers. The first + the last = 5 + 1995 = 2000, so is the second + the second last = 10 + 1990 = 2000. This can be repeated 199 times and then we are left with 1000. So the sum is 199 x 2000 + 1000 = 399000.
The same can be done for 7 and 35, and the answer is 626430 as @doughtaker wrote.

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.030
BTC 65637.68
ETH 2661.86
USDT 1.00
SBD 2.81