#include<iostream> #include<cstdio> using namespace std; int main() { int n; cin>>n; int a=2,b=1;double sum=0; while(n--) { sum=(a*1.0/b)+sum; int temp=a; a=a+b; b=temp; } printf("%.2f",sum); }
Double click to view unformatted code.