Data Structure & Algorithms
DSA
Bit Manipulations
Number of 1 Bits

Number of 1 Bits

Problem Description

Write a function that takes an integer and returns the number of 1 bits present in its binary representation.

Problem Constraints

1 <= A <= 10^9

Input Format

First and only argument contains integer A

Output Format

Return an integer

Example Input

Input 1:
11

Input 2:
6

Example Output

Output 1:
3

Output 2:
2

Example Explanation

Explanation 1:
11 is represented as 1011 in binary.

Explanation 2:
6 is represented as 110 in binary.

Output

Java
 
Python
 
JavaScript