For Loop

Given two integers low and high, return the sum of all integers from low to high inclusive.

Example 1:

Input: low = 1, high = 5

Output: 15

Explanation: 1 + 2 + 3 + 4 + 5 = 15

Example 2:

Input: low = 3, high = 7

Output: 25

Explanation: 3 + 4 + 5 + 6 + 7 = 25

Now Your Turn!

Pick the correct output for the given input

Input: low = 3, high = 8

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 0 <= low <= high <= 100
0
class Solution {
public:
int forLoop(int low, int high) {
// Your code goes here
}
};
Test Case

Input:

High
Low