Pagini recente » Cod sursa (job #2836125) | Cod sursa (job #1408213) | Cod sursa (job #500164) | Cod sursa (job #420242) | Cod sursa (job #921162)
Cod sursa(job #921162)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int power(int a, int b){
int rez=1;
while(b>0){
rez=rez*a;
b--;
}
return rez;
}
int main(){
ifstream f("fact.in");
int P, nr=0;
f>>P;
f.close();
P=4*P;
bool ok=true;
int k=2;
while(ok){
if(floor(P/(power(5,k-2)-1)) == P/(power(5,k-2)-1))
ok=false;
else k++;
}
nr = P/(power(5,k-2)-1) * power(5,k);
ofstream g("fact.out");
g<<nr;
g.close();
return 0;
}