1155 S Sequence

SemiColon
By -
0
URI Online Judge | 1155

S Sequence

Write an algorithm to calculate and write the value of S, S being given by:
S = 1 + 1/2 + 1/3 + … + 1/100

Input

There is no input in this problem.

Output

The output contains a value corresponding to the value of S.
The value should be printed with two digits after the decimal point.
Input SampleOutput Sample



Solution:


#include <stdio.h>
int main()
{
    double i,c, S=0;
    for(i=1; i<=100; i++)
    {
        c=1/i;
        S+=c;
    }
    printf("%.2lf\n",S);
    return 0;
}

Tags:

Post a Comment

0Comments

Post a Comment (0)