Cod sursa(job #1951582)

Utilizator VladTZYVlad Tiganila VladTZY Data 3 aprilie 2017 18:34:10
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int n,temp,i,h;
int main()
{
    f>>n;
    if(n==0)
        g<<"1";
    else
    {
        temp=n*5;
        h=5;
        for(i=1;i<=n;i++)
        {
            h=h*5;
            if(h<temp)
            {
                temp-=5;
            }
            else
            {
                if(h>temp)
                    break;
            }
        }
        g<<temp;
    }
}