Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. double foo(int step) {
  5.     double result = step;
  6.     for (; step > 0; step--) {
  7.         result = (step - 1) + 1./result;
  8.     }
  9.     return result;
  10. }
  11.  
  12.  
  13. int main()
  14. {
  15.     int n = 3;
  16.     double res;
  17.     res = foo(n);
  18.     std::cout<<res;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement