Pagini recente » Cod sursa (job #1505345) | Cod sursa (job #1438643) | Atasamentele paginii Profil Stefan_Zota | Cod sursa (job #1492397) | Cod sursa (job #963722)
Cod sursa(job #963722)
program factorial;
var f : text;
p,y : longint;
s,x : real;
begin
assign(f,'fact.in'); reset(f);
read(f,p);
close(f);
s := 1;
for y := 1 to p do s := s*10;
x := 1; y := 1;
while y < 1000000 do begin
x := x*y; x := trunc(x) mod trunc(s);
if trunc(x) mod trunc(s) = 0 then begin
assign(f,'fact.out'); rewrite(f);
write(f,y);
close(f);
halt;
end
else y := y+1;
end;
if y = 1000000 then write(f,-1);
close(f);
end.