Cod sursa(job #2550141)

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

int findZeros(int nrOfZeros) {
	int comparator = 0;
	int i = 0;
	if (nrOfZeros == 0) {
		return 1;
	}
	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;
}