Cod sursa(job #3170058)

Utilizator andrei_btwAndrei Nastasa andrei_btw Data 16 noiembrie 2023 18:59:07
Problema Factorial Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <iostream>
using namespace std;
int nz(int n) {
    int c2 = 0, c5 = 0;

    for (int i = 2; i <= n; i *= 2) 
    {
        c2 += n / i;
    }

    for (int i = 5; i <= n; i *= 5) 
    {
        c5 += n / i;
    }

    return c5;
}

int main(){
    int p;
    cin>>p;
    int i=1;
    bool ok=false;
    while(ok==false){
        if(nz(i)==p) ok=true;
        i++;
    }
     cout<<i-1;
    return 0;
}