Cod sursa(job #2288737)

Utilizator valentin35Valentin Popescu valentin35 Data 23 noiembrie 2018 20:07:50
Problema Factorial Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.34 kb
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
	ifstream fin("fact.in");
	ofstream fout("fact.out");
	int p, n = 1, np = 0;
	fin >> p;

	for (int i = 1; i <= p; i++)
		n *= i;
	
	while (p != 0)
	{
		np++;
		p /= 10;
	}

	if (n == np) fout << n;
	else fout << -1;

	system("pause");
	return 0;
}