Pagini recente » Monitorul de evaluare | Cod sursa (job #3243251) | Cod sursa (job #1921559) | Cod sursa (job #1236563) | Cod sursa (job #868597)
Cod sursa(job #868597)
program fractii;
var f : text;
n,i,j,nr : longint;
function cond(x,y : longint) : boolean;
var ok : boolean; i,a,b : longint;
begin
a := x; b := y;
while x <> y do
if x > y then x := x - y
else y := y - x;
if (a mod x = 0) and (b mod x = 0) and (x <> 1) 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.