Cod sursa(job #1089874)
| Utilizator | Data | 21 ianuarie 2014 23:55:12 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include<stdio.h>
#include<stdlib.h>
int log5(int a){
int count=0;
while(a/5!=0)
{
count++;
a=a/5;
}
return count;
}
int main(int argc,char** argv){
FILE *fp;
int p;
int count;
if((fp=fopen("fact.in","r"))==NULL){
perror("fact.in :");
return 1;
}
fscanf(fp,"%d",&p);
fclose(fp);
if((fp=fopen("fact.out","w"))==NULL){
perror("fact.out :");
return 1;
}
if(p==0)
fprintf(fp,"%d",1);
else
fprintf(fp,"%d",5*(p-log5(p)));
fclose(fp);
return 0;
}
