Cod sursa(job #2550166)

Utilizator Chr1styDescultu Cristian Chr1sty Data 18 februarie 2020 15:38:28
Problema Factorial Scor 15
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <iostream>
#include <fstream>
using namespace std;

int findZeros(int nrOfZeros) {
	int comparator = 0;
	int i = 0;
	if (nrOfZeros == 0) {
		return 1;
	}

	for (int i = 0; i < nrOfZeros; ++i) {
		if ((i + 1) % 5 == 0) {
			i++;
		}
			comparator += 5;
	}
	return comparator;
	/*while (comparator < nrOfZeros) {
		i += 5;
		int aux = i;
		while (aux % 5 == 0) {
			comparator++;
			aux /= 5;
		}
	}
	return i;*/

}

int main() {
	ifstream myfile;
 	myfile.open("fact.in");
 	ofstream outfile ("fact.out");
 	int nrOfZeros = 0;
 	while(myfile >> nrOfZeros) {
 		outfile << findZeros(nrOfZeros) << '\n';
 	}
 	myfile.close();
 	outfile.close();
 	return 0;
}