View Code of Problem 48

#include<stdio.h>
#include<math.h>
int main()
{

    int n,t;
    double sum,a,b;
    scanf("%d",&n);
    a=2;
    b=1;

    while(n--)
    {
         sum+=a/b;
         t=a;
         a=a+b;
         b=t;
    }
    printf("%.6lf",sum);
    return 0;

}

Double click to view unformatted code.


Back to problem 48