bool isPowerOf2(int i) { if (i == 1) return true; if (i % 2 == 1) return false; return isPowerOf2(i ~/ 2); }