Initialize result with first element of vector
let result = v [ 0 ] ; for ( let i = 1 ; i < v . length ; i ++ ) result = result ^ v [ i ] ; return result ; } function bitcount ( n ) { var count = 0 ; while ( n ) { count += n & 1 ; n >>= 1 ; } return count ; }