Skip to content

Commit

Permalink
count Wagstaff primes
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-chernikov committed Dec 11, 2020
1 parent 4aa31b5 commit 578d457
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void* thr_isPrime(void* data)
}
}
if (found) break;
vData->tbl_start = vData->page[nb_elems - 1] + 2;
vData->tbl_start = vData->page[nb_elems - 1] + 6;
if (vData->tbl_start >= vData->tbl_end) break;
}

Expand Down Expand Up @@ -119,12 +119,12 @@ int isPrime(const mpz_t num, int progress)
return result;
}

PDBElem start = primes[nprimes - 1] + 2;
PDBElem start = primes[nprimes - 1] + 6;
PDBElem tbl_step = tbl_max_val;
if (mpz_cmp_ui(sqrt, tbl_step) < 0) tbl_step = mpz_get_ui(sqrt);
tbl_step = (tbl_step - start) / NCPU;
mpz_t step, div;
mpz_init_set_ui(div, tbl_max_val + 2);
mpz_init_set_ui(div, tbl_max_val + 6);
mpz_init_set(step, sqrt);
mpz_sub(step, step, div);
mpz_div_ui(step, step, NCPU);
Expand Down Expand Up @@ -223,6 +223,7 @@ void findWagstaffPrimesQ(unsigned long long num)
mpz_out_str(stdout, 10, wNum);
printf(" is also a Mersenne prime\n");
}
count++;
}
}
}
Expand Down Expand Up @@ -252,6 +253,7 @@ void findWagstaffPrimesB(unsigned long long num)
mpz_out_str(stdout, 10, wNum);
printf(" is also a Mersenne prime\n");
}
count++;
}
}
}
Expand Down Expand Up @@ -294,7 +296,7 @@ void factorize(const mpz_t num)
fflush(stdout);
}
}
uistart = page[nb_elems - 1] + 2;
uistart = page[nb_elems - 1] + 6;
}
if (mpz_cmp_ui(n, 1) == 0) break;
if (isPrime(n, 0)) {
Expand Down
2 changes: 1 addition & 1 deletion prime_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int pdb_is_prime(const PDBElem n)
if ((n % first_primes[i]) == 0) return 0;
}

PDBElem div = first_primes[n1primes-1] + 2;
PDBElem div = first_primes[n1primes-1] + 6;
while (div < sqroot) {
if ((n % div) == 0) return 0;
div += 2;
Expand Down

0 comments on commit 578d457

Please sign in to comment.