Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
559 B
1
Indexable
//10.	Calcular la siguiente serie (con factorial):
//S=x^1/1!+〖x^2/2!+x^3/3!+ ......+x^n/n!.〗
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int cant = 0, N = 0;
    float x = 0, prod = 0, fact = 1;
    cout << "Ingrese el valor de N: ";
    cin >> N;
    cout << "Ingrese el valor de x: ";
    cin >> x;
    while (cant < N)
    {
        cant = cant + 1;
        fact = fact * cant;
        prod = prod + (pow(x, cant) / fact);
    }
    cout << "La Suma total es: " << prod << endl;
    return 0;
}