Cod sursa(job #600964)

Utilizator ctlin04UAIC.VlasCatalin ctlin04 Data 4 iulie 2011 14:56:19
Problema Fractii Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.72 kb
Program fractii;
 var i, j, t, k, n:longint;
     f:boolean;
     fi, fo:text;
begin
 assign(fi,'fractii.in');
  reset(fi);
   read(fi,n);
    close(fi);
 assign (fo,'fractii.out');
  rewrite(fo);
   if n=1 then begin
                write(fo,'1');
                close(fo);
                exit;
                end;
 k:=n; f:=true;
 for i:=2 to n do
  for j:=1 to n do begin
                    if j=1 then inc(k);
                    if (j<=i) and (j>=2) then
                                           begin
                                        for t:=2 to j do
                                         if (i mod t=0) and (j mod t=0) then
                                                                         begin
                                                                         f:=false;
                                                                         break;
                                                                         end;
                                         if f then inc(k)
                                                 else f:=true;
                                         end
           else if j>i then begin
                              for t:=2 to i do
                               if (i mod t=0) and (j mod t=0) then begin
                                                                  f:=false;
                                                                  break;
                                                                  end;
                               if f then inc(k)
                                      else f:=true;
                              end;
                              end;
    write(fo,k);
    close(fo);
 end.