Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- #include <math.h>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- float suma, czescskladowa, wyrazenie;
- int x, n, i;
- cout << "Podaj wspolczynnik n w celu obliczenia ciagu 1/x + 1/x^2 + 1/x^3 + 1/x^4 + . . . + 1/x^n" << endl;
- cin >> n;
- cout << endl << "Podaj wartosc x" << endl;
- cin >> x;
- suma = 0;
- for (i = 1; i <= n; i++)
- {
- wyrazenie = 1/ x;
- czescskladowa = pow(wyrazenie, i);
- suma = suma + czescskladowa;
- }
- cout << endl << "suma to " << suma << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement