Cod sursa(job #672606)

Utilizator Xavierpana emil Xavier Data 2 februarie 2012 20:04:41
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include<iostream>
#include<fstream>
using namespace std;

ifstream ifile;
ofstream ofile;
int i,c2=0,c5=0,n;

int count2(int x){

    if(x%2==0 && x>=2) return 1 + count2(x/2);
    else return 0;
    
}

int count5(int x){

    if(x%5==0 && x>=5) return 1 + count5(x/5);
    else return 0;
    
}

int main(){
    ifile.open("fact.in");
    ofile.open("fact.out");
    
    ifile>>n;
    //cin>>n;
    
    i=0;
    while(c2<n || c5<n){
         i++;
         c2 += count2(i);
         c5 += count5(i);
    }
    
    ofile<<i;
    //cout<<i;
    
    ifile.close();
    ofile.close();
    system("PAUSE");
    return 0;
}