#C14586. Sum of Even Numbers in a Range
Sum of Even Numbers in a Range
Sum of Even Numbers in a Range
Given two integers start and end, compute the sum of all even numbers in the inclusive range \( [start, end] \). The formula used to calculate the sum when there are \( n \) even numbers ranging from \( a \) to \( b \) is:
\( \text{sum} = \frac{n (a + b)}{2} \)
If the range is invalid or contains no even numbers, the result should be 0.
inputFormat
A single line containing two space-separated integers, representing the start and end of the range.
outputFormat
An integer representing the sum of all even numbers within the given range.## sample
2 10
30