Pagini recente » Cod sursa (job #730821) | Cod sursa (job #264638) | Cod sursa (job #391891) | Statistici Alexandru Galoiu (Alexandru_Galoiu) | 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.