View Code of Problem 48

#include<stdio.h>
int main()
{
  int n;
  double i=2.0,j=1.0,t,x,sum=0.0;
  scanf("%d",&n);
  for(x=1;x<=n;x++)
  {
    sum+=i/j;
    t=i;
    i=i+j;
    j=t;
  }
  printf("%.6lf\n",sum);
  return 0;
}

Double click to view unformatted code.


Back to problem 48