3 ms·
Generating π from 1,000 random numbers
- e0m 10y agoAnd a Tweet-length implementation: https://twitter.com/E0M/status/841673345791803392 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))));
- mrkgnao 10y agoThat 6 is all I needed to see. :)