<script type="text/javascript">
heshu();
function heshu(){
    var str="",n=0;
    for(var i=1; i<=100; i++){
        var m=0; //非合数
        for(var j=2; j<i; j++){
            if(i%j==0){
                m=1; //合数
                break;
            }
        }
        if(m==1 && i!=2){
            str=str + i + ",";
            n++; //合数个数+1
        }
    }
    window.document.write("<p>1-100间的合数总数为:" + n + " 个</p>");
    window.document.write("<p>1-100间的合数分别为:" + str.substr(0,str.length-1) +"</p>");
}
</script>

results matching ""

    No results matching ""