Pagini recente » Cod sursa (job #2717514) | Cod sursa (job #1124508) | Cod sursa (job #2134147) | Cod sursa (job #174821) | Cod sursa (job #104843)
Cod sursa(job #104843)
{infoarena.ro fractii}
var f:text;
j,q:longint;
k,n:longint;
function ireductibile(x,y:longint):boolean;
var d,i,c,r:longint;
begin
if x>y then
begin
d:=x;
i:=y;
end
else
begin
d:=y;
i:=x;
end;
repeat
c:=d div i;
r:=d mod i;
d:=i;
i:=r;
until r=0;
if d=1 then ireductibile:=true
else ireductibile:=false;
end;
begin
assign (f,'fractii.in');
reset (f);
readln (f,n);
close (f);
assign (f,'fractii.out');
rewrite (f);
k:=0;
for j:=1 to n do
for q:=1 to n do
if ireductibile(j,q) then k:=k+1;
writeln(f,k);
close (f);
end.