Generating π from 1,000 random numbersyoutube.com 1 pointe0m9 years ago2 commentsSaveHideCopy link On HNComments−e0mOP9yAnd a Tweet-length implementation: https://twitter.com/E0M/status/841673345791803392for(m=Math,r=a=>m.round(1e9*m.random()),g=(a,b)=>b?g(b,a%b):a,p=0,i=0;i<1e7;i++)if(1==g(r(),r()))p++;console.log(m.sqrt(6/(p/(1e7))));−mrkgnao9yThat 6 is all I needed to see. :)
Comments
And a Tweet-length implementation: https://twitter.com/E0M/status/841673345791803392
for(m=Math,r=a=>m.round(1e9*m.random()),g=(a,b)=>b?g(b,a%b):a,p=0,i=0;i<1e7;i++)if(1==g(r(),r()))p++;console.log(m.sqrt(6/(p/(1e7))));
That 6 is all I needed to see. :)