Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- void aprox(int a) {
- cout.setf(ios::fixed);
- cout.precision(10);
- double res=0;
- double nfac;
- int n=a;
- for (int i=1;i<n;++i) {
- nfac=1/(n*(n-i));
- res=res+nfac;
- cout << res << endl;
- ++i;
- }
- cout << res << endl;
- }
- int main() {
- int n;
- cin>>n;
- aprox(n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement