Skip to content
Snippets Groups Projects
Commit 6b587782 authored by tracer-nju's avatar tracer-nju Committed by guo zling
Browse files

Static hostname: starker-HYM-WXX

       Icon name: computer-laptop
         Chassis: laptop
      Machine ID: 9f936e1bf87b4e7cb0e53e5422bcaf22
         Boot ID: 7f7f08a039ed40d2b473aed355f1e17b
Operating System: Ubuntu 22.04.2 LTS
          Kernel: Linux 5.19.0-45-generic
    Architecture: x86-64
 Hardware Vendor: HONOR
  Hardware Model: HYM-WXX
 10:28:24 up 24 min,  1 user,  load average: 1.70, 1.21, 0.79
parent bfaff0a5
No related branches found
No related tags found
No related merge requests found
......@@ -10,11 +10,15 @@ static int primes[N];
int *sieve(int n) {
assert(n + 1 < N);
for (int i = 0; i <= n; i++)
is_prime[1] = false; is_prime[2] = true; is_prime[3] = true; //ini
for (int i = 5; i <= n; i+=2)
is_prime[i] = true;
for (int i = 2; i <= n; i++) {
if(is_prime[i]) continue;
for(int j = 4; j <= n; j += 2)
is_prime[j] = false;
for (int i = 3; i <= n; i+=2) {
if(!is_prime[i]) continue; //use prime only
for (int j = i + i + i; j <= n; j += (i+i)) {
is_prime[j] = false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment