Ask
your own question, for FREE!
Computer Science
19 Online
The question is: 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. Find the sum of all the multiples of 3 or 5 below 1000. My code is: int x = 1; int y = 0; while (x > 1000) { if (x%3==0){ y = y+x; } ++x; } cout << y; but it doesn't work.
Still Need Help?
Join the QuestionCove community and study together with friends!
#include <iostream> using namespace std; int main() { int x=1,sum=0; while(x<10) { if(x%3==0||x%5==0)//Multiples of 3 and 5 { sum=sum+x;//sum of the multiples } x++; } cout<<sum;//Displaying the Result return 0; } Hope this may helpful to you... If any doubts please ask here....
Can't find your answer?
Make a FREE account and ask your own questions, OR help others and earn volunteer hours!
Join our real-time social learning platform and learn together with your friends!
Join our real-time social learning platform and learn together with your friends!
Latest Questions
VERNEISH:
Two objects are moving along separate linear paths where each path is described by position, d, and time, t.
Maci:
what are the best stock apps for people who want to start investing?
Twaylor:
genuienly how do i get better self control i keep watcing youtube and theres this
IzzyCookie:
|dw:1792074056138:dw| Uhm, I don't know where to ask this, but I'm in college welding at my community college, and I need help learning vertical welding for
thehearken:
not sure if this is considered spam, im sorry if it is, but does anyone have tips
12 hours ago
0 Replies
0 Medals
4 days ago
3 Replies
2 Medals
1 week ago
3 Replies
0 Medals
2 days ago
9 Replies
1 Medal
1 week ago
2 Replies
1 Medal