Cod sursa(job #1552741)
Utilizator | Data | 18 decembrie 2015 16:00:07 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int p,fact=1,ok=1,n=1;
ifstream f("fact.in");
f>>p;
while (ok==1)
{
fact=fact*n;
if(p==0) ok=0;
if(fact%10==0)
{
p=p-1;
fact=fact/10;
if (p==0) ok=0;
}
n+=1;
}
ofstream g("fact.out");
g<<n-1;
return 0;
}