Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,22 @@
var [const] BI=Import("zklBigNum"); // libGMP
fcn lucasSeq(b){
Walker.zero().tweak('wrap(xs){
xm2,xm1 := xs; // x[n-2], x[n-1]
xn:=xm1*b + xm2;
xs.append(xn).del(0);
xn
}.fp(L(BI(1),BI(1)))).push(1,1) // xn can get big so use BigInts
}
fcn metallicRatio(lucasSeq,digits=32,roundup=True){ #-->(String,num iterations)
bige:=BI("1e"+(digits+1)); # x[n-1]*bige*b / x[n-2] to get our digits from Ints
a,b,mr := lucasSeq.next(), lucasSeq.next(), (bige*b).div(a);
do(20_000){ // limit iterations
c,mr2 := lucasSeq.next(), (bige*c).div(b);
if(mr==mr2){
mr=mr2.add(5*roundup).div(10).toString();
return(String(mr[0],".",mr.del(0)),
lucasSeq.idx); // idx ignores push(), ie first 2 terms
}
b,mr = c,mr2;
}
}

View file

@ -0,0 +1,7 @@
metals:="Platinum Golden Silver Bronze Copper Nickel Aluminum Iron Tin Lead";
foreach metal in (metals.split(" ")){ n:=__metalWalker.idx;
println("\nLucas sequence for %s ratio; where b = %d:".fmt(metal,n));
println("First 15 elements: ",lucasSeq(n).walk(15).concat(" "));
mr,i := metallicRatio(lucasSeq(n));
println("Approximated value: %s - Reached after ~%d iterations.".fmt(mr,i));
}

View file

@ -0,0 +1,3 @@
println("Golden ratio (B==1) to 256 digits:");
mr,i := metallicRatio(lucasSeq(1),256);
println("Approximated value: %s\nReached after ~%d iterations.".fmt(mr,i));