public static Interval evensFromTo ( int from , int to ) { if ( from % 2 != 0 ) { if ( from < to ) { from ++ ; } else { from -- ; } } if ( to % 2 != 0 ) { if ( to > from ) { to -- ; } else { to ++ ; } } return Interval . fromToBy ( from , to , to > from ? 2 : - 2 ) ; }
Returns an Interval representing the even values from the value from to the value to .