try also this:

Code:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prime tests</title>
<script type="text/javascript">//<![CDATA[
var primeset = [2, 3, 5, 7, 11, 13];
function isprime(thisnum){
var i;
thisnum = parseInt(thisnum);
if(primeset.indexOf(thisnum) == -1){
// is not in sieve, could be prime
var maxfactor = Math.round(Math.sqrt(thisnum));
var maxprime = primeset.pop();
primeset.push(maxprime);
if(maxfactor > maxprime){
// we must find all other primes between maxprime exclusive and maxfactor inclusive
for(i=maxprime+2;i<=maxfactor;i+=2){
if(isprime(i)){
primeset.push(i);
}
}
}
// now we can check if is prime
for(i in primeset){
if(thisnum % primeset[i] == 0){
return false;
}
}
}
return true;
}
//]]></script>
</head>
<body>
<p><script type="text/javascript">//<![CDATA[
var p;
// for(p=160000;p<200000;p++){
for(p=1600;p<=2000;p++){
if(isprime(p)){
document.write(p + " is ");
}else{
document.write(p + " is not ");
}
document.write("prime <br/>");
}
document.write('in primeset we have:<br/>');
for(p in primeset){
document.write(primeset[p] + ", ");
}
document.write('<br/>');
//]]></script></p>
</body>
</html>

the speed could be improved,

best regards