Last active
August 29, 2015 14:27
-
-
Save zhangys-lucky/abf6aa63c0c344833f09 to your computer and use it in GitHub Desktop.
simple way to generate prime table using C
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
#define N (1<<22)+200 | |
long long prime[N]; | |
void get_prime() | |
{ | |
memset(prime,0,sizeof(prime)); | |
for(int i=2;i<N;i++) | |
{ | |
if(prime[i]==0) prime[++prime[0]]=i; | |
for(int j=1;j<=prime[0]&&(i*prime[j]<N);j++) | |
{ | |
prime[i*prime[j]]=1; | |
if(i%prime[j]==0) break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment