Cod sursa(job #1261850)

Utilizator costeasaracostea sara costeasara Data 12 noiembrie 2014 19:32:45
Problema Fractii Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.38 kb
program fractii;
var f,g:text;i,j,n,nr,x,y:longint;
begin
assign (f,'fractii.in'); reset (f);
assign (g,'fractii.out'); rewrite (g);
while not eof(f) do
begin
readln (f,n);
nr:=0;
for i:=1 to n do
for j:=1 to n do
begin
x:=i; y:=j;
while x<>y do
if x<y then y:=y-x
       else if x>y then x:=x-y;
if y=1 then nr:=nr+1;
end;
writeln (g,nr);
end;
close (f);
close (g);
end.