View Code of Problem 48

#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[100];
	a[0]=1;
	a[1]=2;
	for(int i=2;i<100;i++){
		a[i]=a[i-1]+a[i-2];
	}
	int n;
	cin>>n;
	double sum=0;
	for(int i=0;i<n;i++){
		sum+=1.0*a[i+1]/a[i];
	}
	printf("%.6lf",sum);
} 
/*
Main.c:1:25: fatal error: bits/stdc++.h: No such file or directory
 #include <bits/stdc++.h>
                         ^
compilation terminated.
*/

Double click to view unformatted code.


Back to problem 48