xxxxxxxxxx
36
var primes=[2];
var num=100;
function setup() {
createCanvas(400, 400);
genPrimes(num);
}
function draw() {
background(220);
}
//Generates primes up to the number given
function genPrimes(n)
{
var prm;
for(var i=2; i<n; i++)
{
prm=true;
for(var j=0; j<primes.length && prm; j++)
{
//console.log(num, primes[j]);
if(i%primes[j]==0)
{
prm=false;
}
}
if(prm)
{
primes.push(i);
}
}
console.log(primes);
}