View Code of Problem 48

#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  float a, b, c, i, temp = 0;
  float sum=0;
  a = 1;
  b = 2;
  sum = b/a;
  for(i=1;i<n;i++){
    c = a + b;
    sum += c/b;
    temp = b;
    b = c;
    a = temp;
  }
  printf("%.6f", sum);
}

Double click to view unformatted code.


Back to problem 48