Problem
Given two natural numbers start and end, write a function solution that returns the sum of even numbers between start and end (inclusive).
Constraints
startandendare natural numbers between 1 and 100 inclusive.startis less than or equal toend.- There will always be at least one even number between
startandend.
Test Case
| Test Case Number | start | end | return |
|---|---|---|---|
| 1 | 1 | 10 | 30 |
| 2 | 4 | 8 | 18 |
| 3 | 6 | 6 | 6 |
Explanation for Test Case 1
- When
start = 1andend = 10, the even numbers between 1 and 10 are2, 4, 6, 8, 10, and their sum is2 + 4 + 6 + 8 + 10 = 30.
Explanation for Test Case 2
- When
start = 4andend = 8, the even numbers between 4 and 8 are4, 6, 8, and their sum is4 + 6 + 8 = 18.
Explanation for Test Case 3
- When
start = 6andend = 6, the only even number between them is6, so the sum is6.