Question: Write a for loop to sum all the integers between 1 and 1 0 0 . In 1 7 8 4 , Carl Gauss solved

Write a for loop to sum all the integers between 1 and 100.
In 1784, Carl Gauss solved problem #1 in seconds by noticing that:
1+99=100,2+98=100,3+97=100...(he was 7 years old at the time.)
Write a for loop to compute the sum in #1 using approximately half the number of executions of the for loop in #1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!