Cod sursa(job #681695)

Utilizator Slash95Vlad I. Slash95 Data 17 februarie 2012 17:36:46
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.37 kb
#include <iostream>
#include <fstream.h>
using namespace std;

int putere(int n, int d) {
	int p=0;
	while (n>1){
		if (n%d==0)p++;
		n=n/d;}
	return p;}

int main (void) {
	ifstream f("fact.in");
	ofstream g("fact.out");
	int p, n=1, nm=0;
	f>>p;
	while (nm<p){
		if (putere(n,5)>0) nm=nm+putere(n,5);
		n++;}
	if (n>4) n--;
	g<<n;
	f.close ();
	g.close();}