Safe primes and unsafe primes: Difference between revisions

m
Reformatted to reduce line count
m (Minor edit to C++ code)
m (Reformatted to reduce line count)
Line 283:
#include "sieve_of_eratosthenes.h"
 
int main() {
{
const int limit1 = 1000000;
const int limit2 = 10000000;
Line 301 ⟶ 300:
std::ostringstream out[2];
const char* safety[2] = { "safe", "unsafe" };
for (int p = 2; p < limit2; ++p) {
{
if (!sieve.is_prime(p))
continue;
Line 309 ⟶ 307:
if (p < limit1)
++count1[safe];
if (count2[safe] <= max_print[safe]) {
{
if (count2[safe] > 1)
out[safe] << ' ';
Line 316 ⟶ 313:
}
}
for (int i = 0; i < 2; ++i) {
{
std::cout << "First " << max_print[i] << " " << safety[i] << " primes: " << out[i].str() << '\n';
std::cout << "Number of " << safety[i] << " primes below " << limit1 << ": " << count1[i] << '\n';
1,777

edits