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