#include<stdio.h> int main(){ int n; double sum=0,a=1,b=2,t; scanf("%d",&n); while(n){ sum+=b/a; t=a+b; a=b; b=t; n--; } printf("%.6f",sum); return 0; }
Double click to view unformatted code.