Cod sursa(job #1103927)

Utilizator terrorturtle01Ion George Mihai terrorturtle01 Data 10 februarie 2014 09:36:51
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <fstream>
using namespace std;

int zero(int k){
    long m, z;
    m = 5;
    z = 0;
    while(k/m != 0){
        z+=k/m;
        m *= 5;
    }
    return z;
}

int main()
{
    int P, nrz = 1;
    long N;
    ifstream f("fact.in");
    ofstream g("fact.out");
    f>>P;
    N = 1;
    while(nrz != P){
        nrz = zero(N);
        N++;
    }
    g<<N;
}