Pagini recente » Cod sursa (job #1212060) | Cod sursa (job #2102462) | Cod sursa (job #2576478) | Cod sursa (job #423675) | Cod sursa (job #118120)
Cod sursa(job #118120)
var f,g:text;
ap,n,p,q,a,b:integer;
begin
assign(f,'fractii.in');reset(f);
assign(g,'fractii.out');rewrite(g);
read(f,n);
ap:=0;
p:=1;
for p:=1 to n do
for q:=1 to n do
begin
a:=p;b:=q;
if (a=1) and (b=1) then inc(ap)
else
begin
while a<>b do
begin
if a>b then a:=a-b
else
b:=b-a;
if (a=1) and (b=1) then inc(ap);
end;
end;
end;
write(g,ap);
close(f); close(g);
end.