MCPcopy Index your code
hub / github.com/python/cpython / count_set_bits

Function count_set_bits

Lib/test/test_math_integer.py:39–41  ·  view source on GitHub ↗

Number of '1' bits in binary expansion of a nonnnegative integer.

(n)

Source from the content-addressed store, hash-verified

37# this set is range((n >> i+1) + 1 | 1, (n >> i) + 1 | 1, 2).
38
39def count_set_bits(n):
40 """Number of '1' bits in binary expansion of a nonnnegative integer."""
41 return 1 + count_set_bits(n & n - 1) if n else 0
42
43def partial_product(start, stop):
44 """Product of integers in range(start, stop, 2), computed recursively.

Callers 1

py_factorialFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…