#include<bits/stdc++.h> using namespace std; int main() { double n,c,a=2,b=1,s=0; cin>>n; for(int i=1;i<=n;i++) { s+=a/b; c=a+b; b=a; a=c; } printf("%.6lf\n",s); return 0; }
Double click to view unformatted code.