Cod sursa(job #1332949)

Utilizator ionutnedeleaNedelea Ionut ionutnedelea Data 2 februarie 2015 16:42:09
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include<fstream>
using namespace std;
ifstream f("factorial.in");
ofstream g("factorial.out");
long factorial(int x)
{
    if(x==1)
        return x;
    else
        return x*factorial(x-1);
}
int p,ok,i,y,n,n1;
int main()
{
    f>>p;
    ok=0;
    i=1;
    while(ok==0)
    {   y=p;
        n1=factorial(i);
        n=n1;
        while(n1>0)
            if(n1%10==0)
             {y=y-1; n1=n1/10;}
            else
             break;
             if(y==0)
                ok=1;
                else
                    i++;
                }
       g<<i;
       f.close();
       g.close();
       return 0; }