Cod sursa(job #2233720)

Utilizator TeodorLuchianovTeo Luchianov TeodorLuchianov Data 24 august 2018 11:25:46
Problema Factorial Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <iostream>
#include <fstream>

using namespace std;

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

int main()
{
    int p, n, i;
    in >> p;
    i = 0;
    n = 5;
    if(p == 0){
        out << 1;
        return 0;
    }
    while(true){
        if(i == p){
            break;
        }
        int n2 = n;
        while(n % 5 == 0){
            i++;
            n /= 5;
        }
        n = n2 + 5;
    }
    out << n - 5;
    return 0;
}