Conditions and loops
Add only the even numbers from 1 through the input limit, inclusive.
Examples
Example 1
Input
6
Expected output
12
Example 2
Input
1
Expected output
0
Hints and solution
Hint 1
Check whether the remainder when dividing by 2 equals zero.
Reveal worked answer
The loop checks number % 2 == 0 before adding. For the limit 6, the qualifying values are 2, 4, and 6, which add to 12.