repl.it
@RicardoYalico/

a la otra cierra tu cuenta pe papi

C++

No description

fork
loading
Files
  • main.cpp
  • 0
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <cmath>
using namespace std;

short fact(short n) { return (n <= 1 ? 1 : n*fact(n - 1)); }
 
float serie(short n) {
    float sum = 0;
    for (short num = 1; num <= n; num++) {
        sum += pow(num, num+1) / fact(num);
    }
    return sum;
}
 
int main() {

    short n=3;
   serie (n);
    cout << "El resultado es: " << serie(n) << endl;
    system("pause>0");
    return 0;
}