I want to print this factorial series: 2, 3, 8, 30 in C ++. I put this line to take the series and it does not work:
return factorial (número) + factorial (numero-1);
This is to get the values of the series based on the terms from 1 to 10. For example, if you use the number 4, you give us 30 because the 30 is the fourth element of the series: (2, 3 , 8, 30), and 4! + (4-1)!
This is my code:
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
unsigned long factorial( unsigned long);
int main(){
for( int i=0; i<=10;i++)
cout<<i<<"!"<<factorial (i)<<endl;
return 0;
}
unsigned long factorial (unsigned long numero) {
if( número<=1)
return 1;
else
return factorial ( número) + factorial ( numero-1);
// Se pone esta función, para que en base al término de la serie, se realice
// la operación, es decir si se usa la cuarta posición nos da 30,
// el 30 es el cuarto elemento de la serie : (2,3,8,30 ), 4! + (4-1)!
}