mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-06-07 14:42:41 -04:00
👾
This commit is contained in:
parent
1d44d182e2
commit
a85ed914d3
320 changed files with 0 additions and 0 deletions
bit_manipulation
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# author: bt3gl
|
||||
|
||||
|
||||
def count_ones(n: int) -> int:
|
||||
|
||||
counter = 0
|
||||
|
||||
while n:
|
||||
|
||||
if n & 1:
|
||||
counter += 1
|
||||
|
||||
n >>= 1
|
||||
|
||||
return counter
|
Loading…
Add table
Add a link
Reference in a new issue