Problem
Given two integers start and end, write a function solution that returns the sum of all integers from start to end (inclusive).
Constraints
startandendare integers between -100 and 100 inclusive.startis less than or equal toend.
Test Case
| Test Case Number | start | end | return |
|---|---|---|---|
| 1 | 1 | 10 | 55 |
| 2 | -3 | 3 | 0 |
| 3 | 5 | 5 | 5 |
Explanation for Test Case 1
- When
start = 1andend = 10, the sum of all integers from 1 to 10 is1 + 2 + 3 + ... + 10 = 55.
Explanation for Test Case 2
- When
start = -3andend = 3, the sum of all integers from -3 to 3 is(-3) + (-2) + (-1) + 0 + 1 + 2 + 3 = 0.
Explanation for Test Case 3
- When
start = 5andend = 5, the sum of all integers from 5 to 5 is just5.