Solve a mathematical problem that returns the sum of the first n numbers.
There are a number of algorithms that can be used to solve the same problem.
At this point we need to use loops to add the first n numbers and return the sum.
- n = 8
- Numbers considered are: 1, 2, 3, 4, 5, 6, 7, 8
- Sum will be 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8
The sum will be returned.
- Write the pseudocode for the algorithm (sufficiently commented)
- Derive the function of the running time of the algorithm and express the function in big-oh notation.
- Write the program and test it on four different values: 10, 10,000, 1,000,000, 1,000,000,000. What were your observations on the response time on every respective input? How did the output behave and why?