Metallic ratios: Difference between revisions
Content added Content deleted
(Added Go) |
m (→{{header|zkl}}: tweak) |
||
Line 415: | Line 415: | ||
} |
} |
||
fcn metallicRatio(lucasSeq){ |
fcn metallicRatio(lucasSeq){ |
||
const bige="1e33"; |
const bige="1e33",E=10; // x[n-1]*bige*b / x[n-2] to get our digits from Ints |
||
a,b := lucasSeq.next(), lucasSeq.next(); |
a,b := lucasSeq.next(), lucasSeq.next(); |
||
do(1000){ // limit iterations |
do(1000){ // limit iterations |
||
c:=lucasSeq.next(); |
c:=lucasSeq.next(); |
||
m1,m2 := BI(bige).mul(b) |
m1,m2 := BI(bige).mul(b).div(a), BI(bige).mul(c).div(b); |
||
a,b = b,c; |
a,b = b,c; |
||
if((m1 - m2).abs() |
if((m1 - m2).abs()<E) return(m1.div(E),lucasSeq.idx); // idx ignores push(), ie first 2 terms |
||
} |
} |
||
}</lang> |
}</lang> |