Pagini recente » Cod sursa (job #782297) | Istoria paginii runda/leulloe4/clasament | Cod sursa (job #1090872) | skibidi | Cod sursa (job #868586)
Cod sursa(job #868586)
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 := 0;
for i := 1 to n do
for j := 1 to n do
if cond(i,j) then nr := nr + 1;
assign(f,'fractii.out'); rewrite(f);
write(f,nr);
close(f);
end.