Cod sursa(job #1972166)

Utilizator _Victor_Victor Ciobanu _Victor_ Data 22 aprilie 2017 12:39:04
Problema Fractii Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.48 kb
Program Fractii;
var s,a,b,n,d: longint;
g,f:text;
procedure euclid(a,b:longint;var d:longint); 
begin 
 if b<>0 then begin 
  euclid(b,a mod b,d);
 end else
  d:= a;
end;
begin
assign(f,'fractii.in');reset(f);
assign(g,'fractii.out');rewrite(g);
readln(f,n);
d:= 1;
for a:= 1 to n do begin
 b:= a;
 while b <= n do begin
  euclid(a,b,d);
  if d = 1 then
   s:= s + 2;
   b:= b + 1;
  {if a mod b <> 0 then
   s:= s + 1;}
  end;
 end;
s:= s - 1;
writeln(g,s);
end.