Cod sursa(job #299086)

Utilizator cristinabCristina Brinza cristinab Data 6 aprilie 2009 16:19:51
Problema Frac Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.54 kb
var n,i,j,x,y,nr,r:longint;

begin

assign (input,'fractii.in');
reset (input);

assign (output,'fractii.out');
rewrite (output);

readln (n);

nr:=n;

for i:=2 to n do
    for j:=1 to n do
        begin
        if j=1 then inc (nr)
        else begin
             x:=i;
             y:=j;
             while y<>0 do
                begin
                r:=x mod y;
                x:=y;
                y:=r;
                end;
             if x=1 then inc(nr);
             end;
        end;

writeln (nr);
end.