Ishaan28malik / Hacktoberfest-2023

Make this Hacktoberfest a learning period and contribute to Great Open Source Projects.
MIT License
551 stars 1.71k forks source link

added code for Count_set_bits.cpp program #1991

Open hecker1002 opened 9 months ago

hecker1002 commented 9 months ago

I added a code for counting all the set bits in binary form of a number but apart from the trivial approach , I used a new - Brian Kernighan Algorithm that says if we subtract 1 from a number 'N' , it flips all the bits after the rightmost set bit in the binary .