Cod sursa(job #2188452)

Utilizator raulsomesanRaul Somesan raulsomesan Data 27 martie 2018 10:01:58
Problema Factorial Scor 40
Compilator cpp Status done
Runda bpc9 Marime 0.46 kb
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ifstream fin("fact.in");
    ofstream fout("fact.out");
    int p;
    fin>>p;
    if(p==0)
        fout<<1;
    else
    {
        int x=0;
        int k=0;
        while(k<=p)
        {
            x=x+5;
            int cx=x;
            while(cx%5==0)
            {
                ++k;
                cx=cx/5;
            }
        }
        fout<<x-5;
    }
}