Está en la página 1de 1

// 1. Implementar el factorial de un nro. #include <iostream> #include <cstdlib> using namespace std; // Prototipos.

int LeerN(); int FactorialDe(int); int main() { int x = LeerN(); cout<<"El factorial de "<<x<<" es: "<<FactorialDe(x)<<"\n\n\t\t"; system("pause"); return 0; } // Definiciones de funciones. int LeerN() { int N; cout<<"Ingrese un nro: "; cin>>N; if(N>0) return N; else { cout<<"Ingrese un valor positivo !"<<endl<<endl; return LeerN(); } } int FactorialDe(int N) { int R = 1; for(int i=2; i<=N; ++i) R *= i; return R; }

También podría gustarte