- 1

Using the do-while loop sum all the multiples of 5 between 0 to 100

25th Apr 2017, 9:32 AM
jesse
4 Respuestas
+ 9
Easy with mathematics. int x = 100 / 5; int ans = (((x) * (x + 1)) / 2) * 5; Same answer without any loop. This is more efficient algorithm. 😊
25th Apr 2017, 9:47 AM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar
+ 6
Spam
25th Apr 2017, 9:51 AM
Tim G
Tim G - avatar
- 1
int i=5,sum=0; do{ sum=sum+i; i+=5; }while(i==100); }
25th Apr 2017, 9:39 AM
Swapnil
Swapnil - avatar
- 1
https://code.sololearn.com/c3U5TOU8QCwX/?ref=app There you are even a bit more. Unless I misunderstood what you were going for.
25th Apr 2017, 10:02 AM
James
James - avatar