Created
May 14, 2012 12:56
-
-
Save tomerfiliba/2693796 to your computer and use it in GitHub Desktop.
The most efficient way to compute powers of two!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> x="" | |
>>> for i in range(25): | |
... print i, len(x) | |
... x = repr(x) | |
... | |
0 0 | |
1 2 | |
2 4 | |
3 8 | |
4 16 | |
5 32 | |
6 64 | |
7 128 | |
8 256 | |
9 512 | |
10 1024 | |
11 2048 | |
12 4096 | |
13 8192 | |
14 16384 | |
15 32768 | |
16 65536 | |
17 131072 | |
18 262144 | |
19 524288 | |
20 1048576 | |
21 2097152 | |
22 4194304 | |
23 8388608 | |
24 16777216 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment