Cod sursa(job #2428603)

Utilizator ageneohasMart Florin ageneohas Data 5 iunie 2019 21:31:16
Problema Factorial Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.25 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <fstream>
using namespace std;
long long factorial(long long n)
{
    long long produs=1;
    for (int i=1;i<=n;i++)
    {
        produs*=i; 
    }
    return produs;
}
long howMany(long long n)
{
    long count=0;
    while(n>0)
    {
        if(n%10==0)
        {
            count++;
            n=n/10;
        }
        else
        {
            break;
        }
        
    }
    return count;
}
int main()
{
    ifstream f("fact.in");
    ofstream g("fact.out");
    long long p;
    f>>p;
    long long n=0;
    bool ok=true;
    while(ok)
    {
        long long copie=p;
        long long copien;
        copien=factorial(n);

        if(p==0)
        {
            g<<1;
            break;
        }
        else
        {
            if(p==howMany(copien))
            {
                g<<n;
                break;
            }
        }
        n++;
    }

    return 0;
}