Q2: 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.
Write an algorithm to Find the sum of all the multiples of 3 or 5 below 1000.
1
Expert's answer
2013-02-12T10:29:30-0500
#include <conio.h> #include <iostream>
using namespace std;
void main() { long sum = 0; for (int number = 3; number < 1000; number++) if ((number % 3 == 0) || (number % 5 == 0)) sum += number; cout << "The sum of the multiples of 3 or 5 below 1000 is: " << sum << endl; _getch(); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment