Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5.  
  6. void aprox(int a) {
  7. cout.setf(ios::fixed);
  8. cout.precision(10);
  9.  
  10.  
  11. double res=0;
  12. double nfac;
  13. int n=a;
  14. for (int i=1;i<n;++i) {
  15. nfac=1/(n*(n-i));
  16. res=res+nfac;
  17. cout << res << endl;
  18. ++i;
  19. }
  20. cout << res << endl;
  21. }
  22.  
  23.  
  24. int main() {
  25. int n;
  26. cin>>n;
  27. aprox(n);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement