View Code of Problem 71

#include "iostream"
using namespace std;

int main(){
    int n;
    cin>>n;
    int z=2;
    int m=1;
    double sum=z*1.0/m;
    for(int i=1;i<n;i++){
        int t=z;
        z+=m;
        m=t;
        sum+=z*1.0/m;
    }
    printf("%.2lf\n",sum);
}

Double click to view unformatted code.


Back to problem 71