Problem D
Range Sum
Write the function sum_of_range(start, end, step), which takes in three integers as parameters, start, end, and step. The function should return the sum of all numbers from start to end, both end points included, taking step size steps each increment.
Formally, you should compute the value of
where
Note that we are testing your code differently in this task, please only submit your function definitions, without any code outside the functions! The main python file, which handles input and output, is already provided. You can download and place the main file in the same directory as your python file. You can then run the main python file we provide to try out the samples.
Input
The input to the function will consist of three
parameters.
The first parameter will be an integer
The second parameter will be an integer
The third parameter will be an integer
Output
The output of the function should be one integer, the sum over the given range.
Sample Input 1 | Sample Output 1 |
---|---|
1 10 2 |
25 |
Sample Input 2 | Sample Output 2 |
---|---|
1 10 1 |
55 |
Sample Input 3 | Sample Output 3 |
---|---|
5 10 7 |
5 |