View Code of Problem 71

#include <iostream>
using namespace std;

int main(){
  double t,n,a=2,b=1,sum=0;
  cin>>n;
  for(int j=0;j<n;j++){
    sum += a/b;
    t = a;
    a += b;
    b = t;
  }
  printf("%.2lf",sum);
  return 0;
}

Double click to view unformatted code.


Back to problem 71