Set the rightmost off bit | PHP program to set the rightmost unset bit ; If all bits are set ; Set rightmost 0 bit ; Driver Code
< ? php function setRightmostUnsetBit ( $ n ) { if ( ( $ n & ( $ n + 1 ) ) == 0 ) return $ n ; return $ n | ( $ n + 1 ) ; } $ n = 21 ; echo setRightmostUnsetBit ( $ n ) ; ? >