Skip to content

Commit 7b91d9c

Browse files
authored
Merge pull request #1568 from harsh-1806/correction/fix-log-base-2
correct log n base 2 instead of 2 log n
2 parents c04a6c4 + ecfa4ca commit 7b91d9c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/algebra/binary-exp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Let's write $n$ in base 2, for example:
2929

3030
$$3^{13} = 3^{1101_2} = 3^8 \cdot 3^4 \cdot 3^1$$
3131

32-
Since the number $n$ has exactly $\lfloor \log_2 n \rfloor + 1$ digits in base 2, we only need to perform $O(\log n)$ multiplications, if we know the powers $a^1, a^2, a^4, a^8, \dots, a^{2^{\lfloor \log n \rfloor}}$.
32+
Since the number $n$ has exactly $\lfloor \log_2 n \rfloor + 1$ digits in base 2, we only need to perform $O(\log n)$ multiplications, if we know the powers $a^1, a^2, a^4, a^8, \dots, a^{2^{\lfloor \log_2 n \rfloor}}$.
3333

3434
So we only need to know a fast way to compute those.
3535
Luckily this is very easy, since an element in the sequence is just the square of the previous element.

0 commit comments

Comments
 (0)