calculate prime

Revision en1, by radoan1202, 2024-11-27 20:26:00

void prime() { cs[0] = cs[1] = 1;

for (int i = 4; i < n; i += 2) cs[i] = 1;

for (int i = 3; i * i <= n; i += 2)
{
    if (cs[i] == 1)continue;

    for (int j = i * i; j <= n; j += (i + i))
       cs[j] = 1;
}

}

Tags prime

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English radoan1202 2024-11-27 20:26:00 238 Initial revision (published)