enter data by keyboard and calculate the cousins, and print on the screen the numbers of the number entered in javascript

0
var arreglo=[];
    var num=document.getElementById('num').value;
    if(num == ""){
        alert('Campo Vacio');
    }else{
        document.writeln("Los primos de " +num+ " son: ");
        for(i=1;i<num;i++){
            for(j=1;j<=i;j++){
                if(i%j==0){
                    cont++;
                }
            }
            if(cont==2){
                arreglo[c]=i;
                c++;}
            cont=0;
        }
        document.writeln(arrreglo);
    }
}
    
asked by David Jimenez 02.03.2018 в 22:16
source

0 answers