View Code of Problem 71

#include<iostream>

using namespace std;

int main(void){
    int n;
    double sum=0;
    scanf("%d",&n);
    int a=1,b=2,tmp;
    for(int i=1;i<=n;i++){
        sum+=1.0*b/a;
        tmp=a+b;
        a=b;
        b=tmp;
    }
    printf("%.2lf\n",sum);
}

Double click to view unformatted code.


Back to problem 71