View Code of Problem 48

#include<iostream>
#include<math.h>
using namespace std;

int main()
{

    int n;
    cin>>n;
    double fz=2,fm=1;
    double sum=0;
    while(n--)
    {
        sum+=fz/fm;
        double k=fz;
        fz=fm+fz;
        fm=k;
    }
    printf("%.6lf",sum);
    return 0;
}

Double click to view unformatted code.


Back to problem 48