Cod sursa(job #273823)
| Utilizator | Data | 9 martie 2009 01:51:13 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
var P, value : longint;
f : textfile;
begin
Assign(f, 'fact.in');
Reset(f);
Read(f, P);
Close(f);
value := 0;
case P of
-1 : value := -1;
0 : value := 1;
else
begin
if (P mod 5 = 0) then
begin
value := -1;
end;
if value <> - 1 then
if P >= 10
then dec(P, (P div 5) - 1);
value := 5 * P;
end;
end;
Assign(f, 'fact.out');
Rewrite(f);
Write(f, value);
Close(f);
end.