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