Cod sursa(job #60227)
| Utilizator | Data | 13 mai 2007 10:46:57 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.66 kb |
program fact;
{$mode objfpc}{$H+}
uses
Classes, SysUtils
{ add your units here };
var
p:int64;
procedure calc;
var
c,i,d,z:int64;
begin
i:=5;
c:=0;
d:=0;
while (c<p) do
begin
c:=0;
d:=0;
inc(i,5);
z:=i;
while z div 5 > 0 do
begin
inc(c, z div 5);
z:= z div 5;
end;
end;
if (c=p) then writeln(i) else writeln('-1');
end;
begin
assign(input,'fact.in');reset(input);
assign(output,'fact.out');rewrite(output);
while not eof do
begin
readln(p);
calc;
end;
close(output);
end.
