Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
const PRIME_LIMIT=1_000_000;
|
||||
var [const] BI=Import("zklBigNum"); // libGMP
|
||||
var [const] primeBitMap=Data(PRIME_LIMIT).fill(0x30); // one big string
|
||||
p:= BI(1);
|
||||
while(p.nextPrime()<=PRIME_LIMIT){ primeBitMap[p]="1" } // bitmap of primes
|
||||
|
||||
fcn primeWindows(m,deltas){ // eg (6,4,2)
|
||||
n,r := 0,List();
|
||||
ds:=deltas.len().pump(List,'wrap(n){ deltas[0,n+1].sum(0) }); // (6,10,12)
|
||||
sp:=Data(Void,"1" + "0"*deltas.sum(0));
|
||||
foreach n in (ds){ sp[n]="1" } // "1000001000101"
|
||||
while(n=primeBitMap.find(sp,n+1)){ r.append(n) } // (31, 61, 271,...)
|
||||
r.apply('wrap(n){ T(n).extend(ds.apply('+(n))) }) //( (31,37,41,43), (61,67,71,73), (271,277,281,283) ...)
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
foreach w in (T( T(2), T(1), T(2,2), T(2,4), T(4,2), T(6,4,2) )){
|
||||
r:=primeWindows(PRIME_LIMIT,w);
|
||||
println("Successive primes (<=%,d) with deltas of %s (%,d groups):"
|
||||
.fmt(PRIME_LIMIT,w.concat(","),r.len()));
|
||||
println(" First group: %s; Last group: %s\n"
|
||||
.fmt(r[0].concat(", "),r[-1].concat(", ")));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue