Bitwise OR ( | ) of all even number from 1 to N | Function to return the bitwise OR of all the even numbers upto N ; Initialize result as 2 ; Driver code
function bitwiseOrTillN ( n ) { var result = 2 ; for ( var i = 4 ; i <= n ; i = i + 2 ) { result = result | i ; } return result ; } var n = 10 ; document . write ( bitwiseOrTillN ( n ) ) ;