Pagini recente » Cod sursa (job #1414216) | Cod sursa (job #960277) | Cod sursa (job #2255041) | Monitorul de evaluare | Cod sursa (job #2199043)
#include <stdio.h>
int exponent(int a,int b) {
int s = 0;
while(a%b==0) {
s++;
a=a/b;
}
return s;
}
int main() {
FILE *f = fopen("fact.in","rt");
FILE *g = fopen("fact.out","wt");
int n;
fscanf(f,"%d",&n);
printf("%d\n",n);
int i=1;
int twos = 0;
int fives = 0;
while(1) {
if(i%2==0) {
twos += exponent(i,2);
}
if(i%5==0) {
fives += exponent(i,5);
}
if(twos>=n && fives>=n) {
break;
}
// printf("i:%d twos:%d fives:%d\n",i,twos,fives);
i++;
}
fprintf(g, "%d", i);
fclose(f);
fclose(g);
return 0;
}