Cod sursa(job #642259)

Utilizator penultim_oVijiala Tudor Gabriel penultim_o Data 30 noiembrie 2011 19:47:46
Problema Factorial Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <fstream>
#define L unsigned long
using namespace std;

int main()
{
    ifstream in("fact.in");
    ofstream out("fact.out");
    L n=0,n2,p,i,s=0;
    in >> p;
    if(p==0){out << 1; return 0;}
    while(s<p)
    {
        n+=5;
        n2 = n;
        i=0;
        while(n2%5==0)
        {
            i++;
            n2/=5;
        }
        s+=i;
    }
    out << n;

    return 0;
}