josecarlosgutierrez2002@gmail.com

 avatar
Jose20025
c_cpp
2 years ago
478 B
2
Indexable
Never
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int F, n, i, signo;
    float x, S, P, k;

    cout << "Valor n:";
    cin >> n;
    cout << "Valor x:";
    cin >> x;
    cout << "valor k:";
    cin >> k;
    S = 0;
    P = x;
    signo = 1;
    for (i = 1; i <= n; i++)
    {
        S += (signo * pow(P, i)) / k;
        signo = signo * (-1); //(-1)(-1)(-1)(-1)
    }
    cout << "Sumatoria:" << S << endl;
    return 0;
}