Cod sursa(job #607023)

Utilizator pllkAntti Laaksonen pllk Data 10 august 2011 16:54:35
Problema Factorial Scor 40
Compilator c Status done
Runda Arhiva de probleme Marime 0.37 kb
#include <stdio.h>

int main(void) {
    FILE *tied;
    int p, n, a;
    tied = fopen("fact.in", "r");
    fscanf(tied, "%i", &p);
    fclose(tied);
    for (n = 5; p > 0; n += 5) {
        a = n;
        while (a % 5 == 0) {
            p--;
            a /= 5;
        }
    }
    tied = fopen("fact.out", "w");
    fprintf(tied, "%i\n", n - 5);
    fclose(tied);
    return 0;
}