Cod sursa(job #1271)

Utilizator nod_softwareBudisteanu Ionut Alexandru nod_software Data 13 decembrie 2006 09:31:46
Problema Factorial Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.92 kb
program factorial;
var o2,o5,i,p,aux,nr:longint;
  ok:boolean;
  fin,fout:text;
{*----------------------------------*}
begin
  assign(fin,'fact.in');
  assign(fout,'fact.out');
  reset(fin);
  rewrite(fout);
  readln(fin,p);
  ok:=false;
  nr:=0;
  while not ok do
    begin
      o2:=0;
      o5:=0;
      nr:=nr+1;
      for i:=1 to nr do
        begin
          aux:=i;
          while aux mod 2 = 0 do
            begin
              o2:=o2+1;
              aux:= aux div 2;
            end;
          while aux mod 5 = 0 do
            begin
              o5:=o5+1;
              aux:=aux div 5;
            end;
        end;
      if ((o5 > o2) and   (o2= p)) then
        begin
          ok:=true;
          writeln(fout,nr);
        end;
      if ((o2 > o5) and   (o5= p)) then
        begin
          ok:=true;
          writeln(fout,nr);
        end;
    end;
    close(fout);
end.