Pagini recente » Cod sursa (job #1167832) | Cod sursa (job #42731) | Cod sursa (job #958148) | Cod sursa (job #2550481) | Cod sursa (job #2453181)
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
unsigned int save_tens(unsigned long *p)
{
unsigned int nr = 0;
while (*p % 10 == 0)
{
*p = *p / 10;
nr++;
}
return nr;
}
int main()
{
FILE* f = fopen("fact.in", "rt");
unsigned long n, p=1, i=2, count=0;
fscanf(f, "%lu", &n);
while (count != n)
{
p = (p * i);
p = p % 100000000;
count = count + save_tens(&p);
i++;
printf("%lu %lu \n", p, count);
}
f = fopen("fact.out", "wt");
fprintf(f, "%lu \n", i-1);
fflush(stdout);
fclose(f);
system("pause");
return 0;
}