Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <conio.h>
- using namespace std;
- int main ()
- {
- int n , i=0;
- double s = 0, r;
- cout <<"Input n:";
- cin >> n;
- while(i < n)
- {
- i++;
- r = 1/(pow(2,n));
- s+=r;
- }
- cout <<"Sum=" << s+1;
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement