function mtable(r,c) { junk="\n"; junk+="\n"; junk+="Sieve\n"; junk+="\n"; junk+=""; junk+="\n"; junk+="\n"; junk+="

Variable Prime Sieve

"; junk+="The initial table of values is 20x20. Insert a divisor and submit to color all multiples of this divisor (larger than the divisor) green. Note that values of rows*columns larger than 1,000 will cause slow performance. Enjoy!

\n"; junk+="

\n"; junk+="Divisor = \n"; junk+="\n"; junk+="

\n"; junk+="rows = \n"; junk+="columns = \n"; junk+="

\n"; junk+="\n"; for(i=1;i<=r;i++) { junk+="\n" for(j=1;j<=c;j++) { if ((i!=1)||(j!=1)) { junk+="\n"; } else { junk+="\n"; } } junk+="\n"; } junk+="
\n"; junk+="

\n"; junk+="\n"; document.write(junk) document.close() } function check() { if (document.div.num.value==""||document.div.num.value<=1||document.div.num.value!=Math.floor(document.div.num.value)) { alert('Invalid input') } else { var k=document.div.num.value for(i=1;i<=rows;i++) { for(j=1;j<=columns;j++) { if ((j!=1)||(i!=1)) { if ((((i-1)*columns+j)/k==Math.floor(((i-1)*columns+j)/k))&&(((i-1)*columns+j)>k)) { eval("document.div.a_"+i+"_"+j+".style.backgroundColor=\"#00ff00\"") } } } } } } function mclear() { for(i=1;i<=rows;i++) { for(j=1;j<=columns;j++) { eval("document.div.a_"+i+"_"+j+".style.backgroundColor=\"#ffffff\"") } } } function resize() { var m=document.div.row.value; var n=document.div.column.value; if ((m<=0)||(n<=0)||(m!=Math.floor(m))||(n!=Math.floor(n))) { alert('Ivalidate input') } else { mtable(m,n) } }