We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dff3db3 commit 2b23affCopy full SHA for 2b23aff
src/algebra/bit-manipulation.md
@@ -208,11 +208,8 @@ With the new knowledge in hand we can come up with the following algorithm:
208
209
- Find the highest power of $2$ that is lesser than or equal to the given number. Let this number be $x$.
210
- Calculate the number of set bits from $1$ to $2^x - 1$ by using the formua $x \cdot 2^{x-1}$.
211
-
212
-The next steps needs more explanation.
213
214
- Count the no. of set bits in the most significant bit from $2^x$ to $n$ and add it.
215
-- Subtract $2^x$ from $n$ and Recurse with the algorithm using the new $n$.
+- Subtract $2^x$ from $n$ and repeat the above steps using the new $n$.
216
217
```cpp
218
int countSetBits(int n) {
0 commit comments