Displaying the output when the bit is '1' in binary equivalent of number .
for ( let i = 0 ; i < v . length ; i ++ ) { if ( v [ i ] == 1 ) { document . write ( i ) ; if ( i != v . length - 1 ) document . write ( " " ) ; } } document . write ( " " ) ; }