Skip to content

Instantly share code, notes, and snippets.

@xnuk
Created May 2, 2014 03:10
Show Gist options
  • Save xnuk/645ad173d0ecc7c02436 to your computer and use it in GitHub Desktop.
Save xnuk/645ad173d0ecc7c02436 to your computer and use it in GitHub Desktop.
function p3(a){
var i=a.length-1;
var c=0;
for(;i>=0;i--){
var d=a[i];
d=(d<<1)+d+c;
c=Math.floor(d/100000000);
a[i]=d%100000000;
}
if(c>0)a.unshift(c);
}
var t;
(function(){
var ProgressBar = require('progress');
var bar = new ProgressBar(':bar :percent', { total: 40, complete:"x",incomplete:"p"});
t=Date.now();
var y=[3];
for(var i=1;i<10000;i++){
p3(y);
if(i%250==0)bar.tick();
}
bar.tick();
console.log(Date.now()-t);
var fs=require("fs");
fs.writeFile("./output.txt",y.join(""),null);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment