Cod sursa(job #420557)

Utilizator bOGDy1994Bogdan Maxim bOGDy1994 Data 19 martie 2010 22:31:22
Problema Fractii Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.76 kb
var
   n,p,q,kn,k,t1,t2 : longint;
   f                : text;
begin
     assign(f,'fractii.in'); reset(f);
     readln(f,n);
     close(f);
     kn:=0;
     p:=1;
     while p<=n do
           begin
               q:=1;
               repeat
                     t1:=p;
                     t2:=q;
                     while t1<>t2 do
                           begin
                                if t1>t2 then t1:=t1-t2 else
                                if t2>t1 then t2:=t2-t1;
                           end;
                     if (t1=1) or (q=1) then inc(kn);
                     inc(q);
               until q>n;
               inc(p);
           end;
     assign(f,'fractii.out'); rewrite(f);
     write(f,kn);
     close(f);
end.