Cod sursa(job #2453171)

Utilizator cristi1990anCornea Cristian cristi1990an Data 2 septembrie 2019 18:15:43
Problema Factorial Scor 10
Compilator c-64 Status done
Runda Arhiva de probleme Marime 0.6 kb
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

unsigned long long zero_count(unsigned long long n, unsigned long long i)
{
	unsigned long long count = 0;
	while (n % 10 == 0)
	{
		n = n / 10;
		count++;
	}
	return count;
}

int main()
{
	FILE* f = fopen("fact.in", "rt");
	unsigned long long n, p=1, i=2;
	
	fscanf(f, "%llu", &n);

	while (zero_count(p, i) != n)
	{
		p = (p * i)%1000000000000000;
		i++;
		printf("%llu \n", p);
	}

	f = fopen("fact.out", "wt");

	fprintf(f, "%llu \n", i-1);
	fflush(stdout);

	fclose(f);
	system("pause");
	return 0;
}