Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Created October 8, 2010 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilleiguaran/616290 to your computer and use it in GitHub Desktop.
Save guilleiguaran/616290 to your computer and use it in GitHub Desktop.
int criba(int b){
bool *m = new bool[10000];
m[0] = false;
m[1] = false;
int count = 0;
int j = 0;
for(int i=2; i<=10000; i++)
{
m[i]=true;
}
for(int i=2; i*i<=10000; i++)
{
if(m[i]==true)
{
for(int h=2; i*h<=10000; h++)
{
m[i*h]=false;
}
}
}
while(count < b)
{
if(m[j] == true)
{
count++;
}
j++;
}
return j;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment