//编写一个函数,输入n为偶数时,调用函数求1/2+1/4+…+1/n,当输入n为奇数时,调用函数求/1+1/3+…+1/n
function fnPrint(n){
var sum = 0;
if(n%2==0){
i = 2;
}else{
i = 1
}
while(i <= n){
sum+= 1/i;
i = i+2;
}
return sum;
}
var s = fnPrint(4)
alert(s)