Count Set Bits

Count the number of set bits (1s) in a number's binary representation.

Code

General
bin(n).count('1')

Parameters

Number

Server

More Python Snippets