8000 Update src/algebra/bit-manipulation.md · cp-algorithms/cp-algorithms@0db2c96 · GitHub
[go: up one dir, main page]

Skip to content 65ED

Commit 0db2c96

Browse files
Update src/algebra/bit-manipulation.md
Co-authored-by: Oleksandr Kulkov <adamant.pwn@gmail.com>
1 parent 5d84345 commit 0db2c96

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/algebra/bit-manipulation.md

Lines changed: 1 addition & 1 deletion
< 4B16 td data-grid-cell-id="diff-f55b18e9c988850e9ce428a14de86077cadbd65c6bf600edefd94932b4e1cae8-210-210-1" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">210
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ We can see that the all the columns except the leftmost have $4$ (i.e. $2^2$) se
207207
With the new knowledge in hand we can come up with the following algorithm:
208208
209209
- 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*(2^{x-1})$.
+
- Calculate the number of set bits from $1$ to $2^x - 1$ by using the formua $x \cdot 2^{x-1}$.
211211
212212
The next steps needs more explanation.
213213
- Count the no. of set bits in the most significant bit from $2^x$ to $n$ and add it.

0 commit comments

Comments
 (0)
0