Cod sursa(job #681726)

Utilizator Slash95Vlad I. Slash95 Data 17 februarie 2012 18:01:34
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <iostream>
#include <fstream>
using namespace std;

int putere(int n, int d) {
	int p=0;
	while (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++;
		cout<<nm<<" ";
		cout<<n<<" ";}
	if (n>4) n--;
	g<<n;
	f.close ();
	g.close();}