Pagini recente » Cod sursa (job #1858085) | Statistici Frunza Eduard (eduardcfrunza) | Cod sursa (job #2811541) | Istoria paginii utilizator/mairin | Cod sursa (job #2756491)
#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);
}