Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Created September 15, 2018 01:15
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 completejavascript/37fe43e9f53466a3b541ed79db1242d5 to your computer and use it in GitHub Desktop.
Save completejavascript/37fe43e9f53466a3b541ed79db1242d5 to your computer and use it in GitHub Desktop.
bool* CreatePrimeArray(int n)
{
bool *Prime = new bool[n+1];
for(int i = 0; i <= n; i++)
Prime[i] = true;
Prime[0] = Prime[1] = false;
for(int i = 2; i*i <= n; i++)
if(Prime[i] == true)
{
int j = 2;
while(i*j <= n)
{
Prime[i*j] = false;
j++;
}
}
return Prime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment