Created
April 6, 2018 10:18
-
-
Save JellyWX/ec9fb139ce38d9b6c6d5dc1fd058eee9 to your computer and use it in GitHub Desktop.
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
const int size = 1000000; | |
int main() | |
{ | |
bool li[size] = {false}; | |
for ( int i = 2; i < size; ++i ) | |
{ | |
if ( !li[i] ) | |
{ | |
for ( int j = i *2; j < size; j += i ) | |
{ | |
li[j] = true; | |
} | |
} | |
} | |
} |
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
def sieve(): | |
li = [True for _ in range(1000000)] | |
for i in range(2, len(li)): | |
if li[i] == True: | |
for j in range(i * 2, len(li), i): | |
li[j] = False | |
return li | |
sieve() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment