blob: 6d1075d34d2917a73fe2f6878f12bc4b8acfc6ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
"use strict";
for (let i in Array(21).fill("")) {
let v = flopped(i);
console.log(["", i, v].join("\t"));
}
console.log(["", 86, flopped(86)].join("\t"));
console.log(["", 101, flopped(101)].join("\t"));
console.log(["", 18, flopped(18)].join("\t"));
console.log(["", 33, flopped(33)].join("\t"));
function flopped(n) {
let b = parseInt(n).toString(2);
while (b.length < 8) {
b = "0" + b;
}
let front = b.substring(0, 4);
let back = b.substring(4);
let r = back + front;
let x = parseInt(r, 2);
return x;
}
|