Listado de Números Primos desde el 0 hasta 100.000
Código HTML para la generación de Números Primos pequeños:
<!DOCTYPE HTML>
<html><head></head><body>
<script>
var i,ini,fin,ro,a;
function calc()
{ ini=parseInt(p01.value); fin=parseInt(p02.value);
document.open(); document.write("<!DOCTYPE HTML><HTML><head></head><body>");
for (i=ini;i<fin;i++)
{ p=1; a=2;
ro=parseInt(Math.sqrt(i))+1;
while (a<ro)
{ if (i%a==0){ p=0; break; }
a=a+1; }
if(p!=0)document.write(i,"<br>"); }
document.write("</body></html>"); document.close(); }
</script>
<br>Val. Inicial:<input type="text" id="p01" >
<br>Valor Final:<input type="text" id="p02" >
<br><a href="JavaScript:calc()">CALCULAR</a>
</body></html>
No comments:
Post a Comment