Cod sursa(job #1321376)
Utilizator | Data | 19 ianuarie 2015 02:13:54 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
int n;
int suma = 1;
int fact = 0;
ifstream f("fact.in");
ofstream g("fact.out");
f >> n;
if (n == 0)
{
g << "-1";
return 0;
}
while (n != 0)
{
if (suma % 10 == 0)
{
n--;
suma = suma / 10;
}
suma =suma * (fact+1);
fact ++;
}
g << fact-1;
f.close();
g.close();
}