Cod sursa(job #548284)

Utilizator CehashishChis Ovidiu Cehashish Data 7 martie 2011 11:58:30
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include<iostream.h> 
#include<fstream.h> 

 
ifstream f; 
ofstream g; 
unsigned long int a,b,aux,nr;  
 
void facto(unsigned long int n) 

{ 
g.open("fact.out"); 


a=0; 
b=0; 
    
while(b<n) 
    
{a=a+5; 
      
aux=a; 
      
while(aux!=0) 
      
{ if(aux%5==0) 
        
b++; 
      
aux=aux/5; 
        
} 
     
} 
 
if(b==n) g<<a<<endl; 
else g<<"-1"<<endl; 

 
n--; 
} 

 
int main() 

{ 
     
unsigned long int m; 
    
f.open("fact.in"); 

f>>m; 
facto(m); 
f.close(); 
g.close(); 
return 0; 
}