mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-08 06:43:14 +08:00
Update count_of_set_bits.cpp
This commit is contained in:
@@ -28,7 +28,7 @@ namespace bitCount {
|
|||||||
* @returns count , the number set bit in binary representation of n
|
* @returns count , the number set bit in binary representation of n
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::uint64_t countSetBits(unsigned int n) {
|
std::uint64_t countSetBits(int n) {
|
||||||
int count = 0; // "count" variable is used to count number of 1's in binary representation of the number
|
int count = 0; // "count" variable is used to count number of 1's in binary representation of the number
|
||||||
while (n!=0) {
|
while (n!=0) {
|
||||||
count += n & 1;
|
count += n & 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user