Cod sursa(job #1436435)

Utilizator istrate.cristianIstrate Cristian istrate.cristian Data 15 mai 2015 21:46:34
Problema Factorial Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <fstream>

using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

int main()
{
    int n=0,p,i,cop;
    f>>p;
    if(p==0)
        g<<-1;
    else
    {
        n=p*5;
        for(i=5; i<=n; i+=5)
        {
            cop=i;
            while(cop/5%5==0)
            {
                n-=5;
                cop/=5;
            }
        }
        g<<n;
    }
    return 0;
}