Cod sursa(job #548302)

Utilizator CehashishChis Ovidiu Cehashish Data 7 martie 2011 12:23:50
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<iostream.h> 
#include<fstream.h> 

 
ifstream f; 
ofstream g; 
unsigned long int a,b,aux;  
 
void facto(unsigned long int n) 
{
g.open("fact.out"); 
if(n==0) g<<'1';
else
{
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; 

} 
}
 
int main() 

{ 
unsigned long int m; 
f.open("fact.in"); 
f>>m; 
f.close();
facto(m); 
g.close();
return 0; 
}