Pagini recente » com2009 | Cod sursa (job #183492) | Rating Iesan Tudor (TDRking) | Cod sursa (job #2065045) | Cod sursa (job #903856)
Cod sursa(job #903856)
program factorial;
var
p,fact:longint;
i:longint;
f,g:text;
ok:boolean;
{function fact(i:longint):longint;
begin
if i=0 then fact:=1
else fact:=i*fact(i-1);
end; }
function putere(p:longint):longint;
begin
if p=0 then putere:=1
else putere:=10*putere(p-1);
end;
begin
assign(f,'fact.in');reset(f);
assign(g,'fact.out');rewrite(g);
readln(f,p);
i:=p;
ok:=false;
fact:=1;
while (ok=false) do if fact mod putere(p)=0 then ok:=true
else begin i:=i+1; fact:=fact*i; end;
if i=0 then write(g,i+1)
else write(g,i);
close(f);close(g);
end.