View Code of Problem 48

#include<stdio.h>
void main(){
  int n;
  double sum=0,p=1.0,q=2.0,t;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
  	sum =sum + q/p;
    	t = q;
    	q = p + q;
    	p = t;
  }
  printf("%.6lf",sum);
}

Double click to view unformatted code.


Back to problem 48