Pagini recente » Cod sursa (job #2309465) | Cod sursa (job #3122294) | Cod sursa (job #2386214) | Cod sursa (job #2567683) | Cod sursa (job #868619)
Cod sursa(job #868619)
program fractii;
var f : text;
n,i,j,nr : longint;
function cond(x,y : longint) : boolean;
var ok : boolean; r,a,b : longint;
begin
if x > y then begin a := x; b := y; end
else begin b := x; a := y; end;
while b <> 0 do begin
r := a;
a := b; b := r div b;
end;
if (a <> 1) and (x mod a = 0) and (y mod a = 0) then cond := false
else cond := true;
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.