求和
let sum=0;
for(var i=0;i<=100;i++){sum+=i;}
console.log(sum);//5050
求偶求奇和
let sum=0;
for(var i=0;i<=100;i+=2){sum+=i;}
console.log(sum);//2550
<------ 黄金分割线 ------->
let sum=1;
for(var i=1;i<=100;i+=2){sum+=i;}
console.log(sum);//2501
求质数
var flag;
var arr=[];
for(var i=2;i<=100;i++){
flag=true;
for(var j=2;j<i;j++){if(i%j===0){flag=false;}
}
if(flag){arr[arr.length]=i;
}
}
console.log(arr);//[2, 3, 5, 7, 11, 13, 17, ........, 83, 89, 97]