Sum of even numbers in a range
PHP
Easy
functions
Task «Sum of even numbers in a range»
Write a function sumEven($start, $end) that takes two integers start and end (inclusive) and returns the sum of all even numbers in this range. If start is greater than end, the function should return 0.
Input Format
Two integers separated by a space or a line break.
Output Format
One integer — the sum of even numbers.
Examples
Example 1
INPUT
2 10
OUTPUT
30
Example 2
INPUT
1 5
OUTPUT
6
main.php