Cod sursa(job #557647)

Utilizator sergiu.apostulApostul Sergiu sergiu.apostul Data 16 martie 2011 19:08:35
Problema Fractii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.74 kb
program fractii;
var n,i,j,c,k,d:longint;
    f:text;
begin
 assign(f,'fractii.in');
 reset(f);
 readln(f,n);
 close(f);
 for i:=1 to n do
  for j:=1 to n do
   begin
    if (i=1)or(j=1) then
     inc(c)
    else
      if (i<>j)and(j mod i<>0)and(i mod j<>0) then
       if i<j then
        begin
         d:=0;
         for k:=2 to i do
          if (j mod k=0) and (i mod k=0) then
           inc(d);
         if d=0 then
          inc(c);
        end
       else
        begin
         d:=0;
         for k:=2 to j do
          if (i mod k=0) and (j mod k=0) then
           inc(d);
         if d=0 then
          inc(c);
        end;
    end;
 assign(f,'fractii.out');
 rewrite(f);
 write(f,c);
 close(f);
end.