Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. double kocham_piwo(double n)
  7. {
  8. if(n==1) return 0.5;
  9. else return (n/(n+1))+ kocham_piwo(n-1);
  10.  
  11.  
  12. }
  13.  
  14. int main()
  15. {
  16. double a;
  17.  
  18. cin>>a;
  19. cout.precision(5);
  20.  
  21. cout<<fixed<<kocham_piwo(a);
  22.  
  23. pawel
  24.  
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement