Checking whether a number is a power of two by dividing repeatedly works, but a single bit test does it in O(1). A power of two has exactly one bit set, so n & (n - 1) is 0 only for those numbers (when n is positive). This matters for hash table sizes and memory alignment, which are often powers of two. Remember to reject zero and negative numbers first.