Sum of consecutive integers
(a) Write a program that prompts for an integer—let’s call it X—and then finds the sum ofX consecutive integers starting at 1. That is, if X = 5, you will find the sum of 1 + 2 + 3 + 4+ 5= 15.
(b) Modify your program by enclosing your loop in another loop so that you can find consecutive sums. For example, if 5 is entered, you will find five sums of consecutive numbers:
1 = 11+ 2 = 31+2+3 = 61+2+3+4 = 101+2+3+4+5 = 15Print only each sum, not the arithmetic expression.
(c) Modify your program again to only print sums if the sum is divisible by the number of operands. For example, with the sum 1 + 2 + 3 + 4 + 5=15, there are five operands and the sum, 15, is divisble by 5, so that sum will be printed. (Do you notice a pattern?)
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.