xxxxxxxxxx
67
function setup() {
createCanvas(400, 400);
//frameRate(1);
}
var t=1; // Iterating check
var n=t;
var steps=0;
var oddsteps=0;
var evensteps=0;
var totalsteps=0;
var moststeps=0;
function draw() {
// background(220);
// var oddpct=(oddsteps/totalsteps);
// var evenpct=(evensteps/totalsteps);
// rect(0, oddpct*height, width/2, height-oddpct*height);
// rect((width/2)+1, evenpct*height, width/2, height-evenpct*height);
// text(evensteps, width/2+width/4, height -10)
// text(oddsteps, 50, height-10);
//console.log(oddpct, evenpct);
//text(n, width/2, height/2);
if(n%2)
{
n=(n*3)+1;
}
else
{
n=n/2;
}
steps++;
//if((n==4) || (n==2) || (n==1))
if(n==1)
{
//if(steps>= moststeps)
{
console.log(t + " hit " + n + " in " + steps +" steps");
moststeps=steps;
}
if(t%2)
{
oddsteps+=steps;
}
else
{
evensteps+=steps;
}
totalsteps+=steps;
t++;
n=t;
steps=0;
}
}