Counting Even and Odd Numbers in a Range
Counting only the evens in a range needs one extra step: evens advance two at a time, so the distance between the ends must be halved before the usual plus one is added.
Counting only the evens in a range needs one extra step: evens advance two at a time, so the distance between the ends must be halved before the usual plus one is added.
Counting only the even numbers in a range needs one extra step beyond the ordinary count. Evens advance two at a time, so the distance between the ends has to be halved before the usual is added.
Count of evens , and count of odds .
The two formulas are identical in shape. All that changes is which endpoints you pick — the first and last even number inside the range, or the first and last odd one.
Each jump covers , so there are jumps. Adding for the starting number gives — exactly the count.
It is the same fence-post idea as before, with one difference: the posts now stand two units apart, so the distance must be divided by the step before counting.
How many even numbers lie between and ?
Both endpoints happen to be odd here, so excluding them changes nothing for the evens. Had the range been to "between", the first even would have been .
How many odd numbers lie between and ?
A useful cross-check: all the numbers between and total , and . Every number is either even or odd, so the two counts must add to the whole.
How many even numbers are there from to ?
Fractional endpoints are not a special case. Turn them into decimals, step inward to the nearest even number at each end, then use the same formula.