fork download
  1. #include<stdio.h>
  2. int f( double h ) ;
  3. int main()
  4. {
  5. double a,n,s ;
  6. s=0;
  7. scanf("%lf",&n);
  8. for(a=1;a<n;a++)
  9. {
  10. s=s+f(a+2)/f(a+1);
  11. }
  12. printf("%.6f",s);
  13. return 0 ;
  14. }
  15. int f ( double h )
  16. {
  17. if((h==1)||(h==2))
  18. {
  19. return 1 ;
  20. }
  21. else
  22. {
  23. return f(h-1)+f(h-2) ;
  24. }
  25. }
Success #stdin #stdout 0.01s 5328KB
stdin
3
stdout
3.000000