Strong and weak primes: Difference between revisions

m
Reformatted to reduce line count
m (Minor edit to C++ code)
m (Reformatted to reduce line count)
Line 311:
#include "sieve_of_eratosthenes.h"
 
int main() {
{
const int limit1 = 1000000;
const int limit2 = 10000000;
Line 331 ⟶ 330:
const char* strength[2] = { "strong", "weak" };
int p1 = 2, p2 = 3;
for (int p3 = 5; p2 < limit2; ++p3) {
{
if (!sieve.is_prime(p3))
continue;
int diff = p1 + p3 - 2 * p2;
int index = diff < 0 ? 0 : (diff > 0 ? 1 : -1);
if (index != -1) {
{
++count2[index];
if (p2 < limit1)
++count1[index];
if (count2[index] <= max_print[index]) {
{
if (count2[index] > 1)
out[index] << ' ';
Line 352 ⟶ 348:
p2 = p3;
}
for (int i = 0; i < 2; ++i) {
{
std::cout << "First " << max_print[i] << " " << strength[i] << " primes: " << out[i].str() << '\n';
std::cout << "Number of " << strength[i] << " primes below " << limit1 << ": " << count1[i] << '\n';
1,777

edits