Cod sursa(job #2756491)
| Utilizator | Data | 1 iunie 2021 01:48:52 | |
|---|---|---|---|
| Problema | Factorial | Scor | 85 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <stdio.h>
#include <math.h>
const int range = 10;
int nrzerofact(int n){
int maxim = 0;
int copie = n;
while(copie) {
copie = copie/5;
maxim++;
}
int suma=0;
for(int i=1; i<maxim; i++){
suma+=n/pow(5,i);
}
return suma;
}
int main() {
FILE *in = fopen("fact.in", "r");
FILE *out = fopen("fact.out", "w");
int P, aux=1;
fscanf(in, "%d", &P);
int k=P/5-range;
if(k<0)k=0;
while(nrzerofact((P-k)*5)!=P){
k++;
}
fprintf(out,"%d", (P-k)*5);
}
