Programs are subject to code, the calculation sequence 1 + 1/3 + 1/5 +... The sum of first N items,
Input format:
The input is given a positive integer N in one line,
The output format:
In a line, in accordance with the "sum=S" the format of the output section and the value of S, accurate to decimal point 6, subject to ensure that the results of calculation scope of no more than double,
Input the sample:
23
The output sample:
Sum=2.549541
My code:
# include & lt; stdio.h>
Int main (void)
{
int n;
Double sum=0;
The scanf (" % d ", & amp; n);
For (n. n> 0; N=n - 2) {
Sum=sum + 1.0/n;
}
Printf (" sum=%. 6 f ", sum);
}