View Code of Problem 48

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

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

Double click to view unformatted code.


Back to problem 48