const arr = [2,4,16]; let v = 0; for(const i in arr) v |= arr[i]; console.log(v);
let xxx = 23;// 16 4 2 let r = []; let i = 0; while (xxx > 0) { const x = xxx & Math.pow(2, i); if (x) { xxx -= x; r.push(x); } i++; }
2022-10-17 12:48:37
const arr = [2,4,16]; let v = 0; for(const i in arr) v |= arr[i]; console.log(v);
let xxx = 23;// 16 4 2 let r = []; let i = 0; while (xxx > 0) { const x = xxx & Math.pow(2, i); if (x) { xxx -= x; r.push(x); } i++; }