Computer Science, asked by Suhab2358, 1 year ago

Find the sum of all the multiples of 3 or 5 below 1000 java

Answers

Answered by Nishurao
0
Hey dear here is ur ans..
To find n use 1000/3 = 333 + remainder, 1000/5 = 200 + remainder, 1000/15 = 66 + remainder and then sum multiples of 3: 3 ⋅ 333 ( 333 + 1 ) / 2 = 166833 . multiples of 5: 5 ⋅ 200 ( 200 + 1 ) / 2 = 100500 and subtract multiples of 15 15 ⋅ 66 ( 66 + 1 ) / 2 = 33165 to get 234168.
hope it will help u..
Similar questions