Cod sursa(job #2237506)

Utilizator vlad082002Ciocoiu Vlad vlad082002 Data 2 septembrie 2018 01:09:45
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <iostream>
#include <fstream>

using namespace std;

int main () {

     int p, n = 1, f = 1, i = 1;
     bool gasit = false;

     ifstream in ("fact.in");
     in >> p;
     in.close();

     for (int i = 1; i <= p; i++) {
          n *= 10;          
     }

     do {
          f *= i;

          if (f % n == 0) {
               ofstream out ("fact.out");
               out << i;
               out.close();
               gasit = true;
          } else {
               i++;
          }

     } while (!gasit);

     return 0;
}