Pagini recente » Cod sursa (job #1208878) | Cod sursa (job #2191826) | Cod sursa (job #2756367) | Cod sursa (job #1711106) | Cod sursa (job #567352)
Cod sursa(job #567352)
var f,g:text;
k,i,j,n,d:integer;
begin
assign(f,'fractii.in');reset(f);
assign(g,'fractii.out');rewrite(g);
while not eof(f) do begin
readln(f,n);
k:=0;
for i:=1 to n do
for j:=1 to n do begin
if (i=1) or (j=1) then k:=k+1;
if (j<>1) and (i mod j<>0) or (j mod i<>0) then begin
if i>j then d:=i-j
else d:=j-1;
if d=1 then k:=k+1;
if d>1 then
if (i mod d<>0) and (j mod d<>0) then k:=k+1;
end;
end;
writeln(g,k);
end;
close(f);
close(g);
end.