Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 706e378

Browse files
author
Oleksandr Kulkov
authored
a^logn -> a^{2^logn} for binary exp
1 parent 4578839 commit 706e378

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
@@ -23,7 +23,7 @@ Let's write $n$ in base 2, for example:
2323

2424
$$3^{13} = 3^{1101_2} = 3^8 \cdot 3^4 \cdot 3^1$$
2525

26-
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^{\lfloor \log n \rfloor}$.
26+
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}}$.
2727

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

0 commit comments

Comments
 (0)