Cod sursa(job #187903)

Utilizator cotofanaCotofana Cristian cotofana Data 5 mai 2008 19:58:23
Problema Factorial Scor 45
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <stdio.h>

long n;
int nr;

void cit()
{
        FILE *f=fopen("fact.in", "r");
        fscanf(f, "%d", &n);
        fclose(f);
}

void tip()
{
        FILE *f=fopen("fact.out", "w");
        fprintf(f, "%d\n", nr);
        fclose(f);
}

void fct()
{
        int i=1,t;
        while (nr<n)
        {
                t=i;
                if (t%5==0) nr++;
                do
                {

                         if (t%5==0) t/=5;
                        nr++;
                } while (t%5==0);
                i++;
        }
        nr=5*(i-1);
}

int main()
{
        cit();
        fct();
        tip();
        return 0;
}