Can someone help me how to program C++ The sum of the first 10 natural numbers? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone help me how to program C++ The sum of the first 10 natural numbers?

https://code.sololearn.com/cFzulHmLc44C/?ref=app https://code.sololearn.com/cFzulHmLc44C/?ref=app

25th Jan 2021, 1:46 PM
Hyacenth Luyas
Hyacenth Luyas - avatar
8 Answers
+ 9
I don't see anything wrong with your code. What's the problem?
25th Jan 2021, 1:48 PM
XXX
XXX - avatar
+ 3
the sum of the first n consecutive numbers is n*(n+1)/2 get first link is how that formula was determined, so that you don't have to memorize it, you'll be able to deduce it yourself.
26th Jan 2021, 1:44 PM
lion
lion - avatar
+ 1
Okay, thank you!
25th Jan 2021, 1:49 PM
Hyacenth Luyas
Hyacenth Luyas - avatar
+ 1
there's a formula for the sum of a series of consecutive numbers, so instead of a for loop, you could have one expression
26th Jan 2021, 6:15 AM
lion
lion - avatar
0
Can you teach me, please
26th Jan 2021, 11:28 AM
Hyacenth Luyas
Hyacenth Luyas - avatar
0
get, what link is that?
26th Jan 2021, 12:24 PM
Hyacenth Luyas
Hyacenth Luyas - avatar
0
"Write a program that adds the numbers until user enters 0." How to program this?
27th Jan 2021, 11:05 AM
Hyacenth Luyas
Hyacenth Luyas - avatar