Skip to content
Skein

Brian Kernighan's algorithm

RU: алгоритм Брайана Кернигана

A method for counting set bits: n &= n - 1 clears the lowest set bit, so looping until n reaches zero takes one iteration per set bit. Its cost is O(number of set bits), not O(word size).

shortcutsexpand
search
⌘K
prev piece
k
next piece
j
cycle tier
t
this menu
?