Cod sursa(job #3232300)

Utilizator Gergo123Schradi Gergo Gergo123 Data 29 mai 2024 21:06:20
Problema Factorial Scor 5
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream fin("fact.in");
ofstream fout("fact.out");

int hanyszamjegy(int n){
    int n1=n,db=0;
    while(n1>0){
        db++;
        n1=n1/10;
    }
    return db;
}

int main()
{
    int p,n=1,index=2;
    fin>>p;
    if(p==0) fout<<n;
    else{
    bool kell=true;
    while(kell){
        if(hanyszamjegy(n)==p && n%10==0) kell=false;
        else{
            n=n*index;
            index++;
        }
    }
    fout<<n;
    }
    return 0;
}