Cod sursa(job #2592877)

Utilizator Tudor_EnacheEnache Tudor Tudor_Enache Data 2 aprilie 2020 16:11:51
Problema Factorial Scor 5
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.35 kb
#include <fstream>

using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");

int factorial (int n){
    int p = 1;
    for (int i = 0; i < n; i++)
        p = p * i;
    return p;
}
int main(){
    int n;
    fin >> n;
    if (n >=  0 and n <= 100000000)
        fout << factorial (n);
    else
        fout << '-1';
}