double sum=0.0; for(int i=n; i>0; i--) { sum+=1.0/(double)i; } return sum;