Pagini recente » Cod sursa (job #2023827) | Cod sursa (job #2001224) | Cod sursa (job #1121983) | Cod sursa (job #360487) | Cod sursa (job #2453195)
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
void save_tens(unsigned long *p, unsigned long* n)
{
while ((*p % 10 == 0)&&(*n))
{
*p = *p / 10;
*n = *n - 1;
}
}
int main()
{
FILE* f = fopen("fact.in", "rt");
unsigned long n, p = 1, i = 2;
fscanf(f, "%lu", &n);
while (n)
{
p = (p * i) % 1000000;
save_tens(&p, &n);
printf("%d %d \n", p, n);
i++;
}
f = fopen("fact.out", "wt");
fprintf(f, "%lu \n", i-1);
fflush(stdout);
fclose(f);
return 0;
}