Count Odd and Even numbers in a range from L to R | Return the number of odd numbers in the range [ L , R ] ; if either R or L is odd ; Driver Code
function countOdd ( L , R ) { let N = Math . floor ( ( R - L ) / 2 ) ; if ( R % 2 != 0 L % 2 != 0 ) N += 1 ; return N ; } let L = 3 , R = 7 ; let odds = countOdd ( L , R ) ; let evens = ( R - L + 1 ) - odds ; document . write ( " " + odds + " " ) ; document . write ( " " + evens + " " ) ;