Cod sursa(job #2060339)

Utilizator valentin12Valentin Ion Semen valentin12 Data 8 noiembrie 2017 08:49:48
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>

using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int fact(int n)
{int i,fact=1;
for(i=1;i<=n;i++)
fact=fact*i;
return fact;

}
int main()
{int n,p,factorial,cif,c;
bool cond=0;
    f>>p;n=0;
while(cond==0)
{c=0;
factorial=fact(n);
while(factorial)
{cif=factorial%10;
if(cif==0) c++;
else break;
factorial=factorial/10;
}
if(c==p) { cond=1;
           g<<n;
         }
n++;
}

    return 0;
}