Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double power(double a, double b)
- {
- double i, res = 1;
- for (i = 0; i < b; i++)
- {
- res = res*a;
- }
- return res;
- }
- double azeret(double a)
- {
- double res =1 , i;
- for (i = 1; i <= a; i++)
- {
- res = res*i;
- }
- return res;
- }
- int main()
- {
- double n, x, i, sum = 0;
- cout << "Enter N: ";
- cin >> n;
- cout << "Enter X: ";
- cin >> x;
- sum = 1 + x;
- cout << "1 + " << x;
- for (i = 2; i < n; i++) {
- cout << "+";
- cout << power(x, i) << "/" << azeret(i);
- sum = sum + power(x, i) / azeret(i);
- }
- cout << "=" << sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement