xxxxxxxxxx
69
var check=1; // Number we want factors for
var numfound=0;
var facts=[];
var factors="";
var tot=0;
var start=2;
var sample =719;
var highest=0;
var primes="2";
function setup() {
createCanvas(400, 400);
for(var j=start; j<=sample; j+=1)
{
check=j;
var half=floor(check/2)+1;
for(var i=1; i<=half; i++)
{
if(check%i==0)
{
numfound++;
facts.push(i);
}
}
for(var i=0; i<facts.length; i++)
{
tot+=facts[i];
if(i>0)
{
factors+="," + facts[i];
}
else
{
factors+=facts[i];
}
}
//if(facts.length>highest)
if(numfound==1)
{
if(primes.length<355)
{
primes+=check;
}
console.log(check + " has " + numfound + " factors.");
console.log(factors);
console.log("TOTAL: " + tot);
console.log("*******************************");
highest=facts.length;
}
tot=0;
facts.length=0;
factors="";
numfound=0;
}
console.log(primes.length);
console.log("primes: " + primes);
}