mirror of
				https://github.com/autistic-symposium/master-algorithms-py.git
				synced 2025-11-03 22:54:02 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			12 lines
		
	
	
	
		
			215 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			12 lines
		
	
	
	
		
			215 B
		
	
	
	
		
			Python
		
	
	
	
	
	
def count_ones(n: int) -> int:
 | 
						|
        
 | 
						|
        counter = 0
 | 
						|
        
 | 
						|
        while n:
 | 
						|
            
 | 
						|
            if n & 1:
 | 
						|
                counter += 1
 | 
						|
            
 | 
						|
            n >>= 1
 | 
						|
        
 | 
						|
        return counter
 |