Pagini recente » Cod sursa (job #1380561) | Cod sursa (job #1900926) | Cod sursa (job #2721035) | Cod sursa (job #2109589) | Cod sursa (job #868589)
Cod sursa(job #868589)
program fractii;
var f : text;
n,i,j,nr : longint;
function cond(x,y : longint) : boolean;
var ok : boolean; i,a,b : longint;
begin
ok := true;
if x > y then begin a := y; b := x; end
else begin a := x; b := y; end;
i := 2;
while (i <= a) and ok do begin
if (a mod i = 0) and (b mod i = 0) then ok := false;
i := i + 1;
end;
cond := ok;
end;
begin
assign(f,'fractii.in'); reset(f);
read(f,n); close(f);
nr := 1;
for i := 1 to n do
for j := 1 to n do
if (i <> j) and cond(i,j) then nr := nr + 1;
assign(f,'fractii.out'); rewrite(f);
write(f,nr);
close(f);
end.