Pagini recente » Cod sursa (job #502025) | Cod sursa (job #1962632) | Cod sursa (job #2070919) | Cod sursa (job #1761829) | Cod sursa (job #741614)
Cod sursa(job #741614)
program ia;
var
i,j,n,k:longint;
fIn,fOut:text;
function common_divisor(x,y:integer):boolean;
var
b,i,j:integer;
a:array of integer;
begin
common_divisor:=false; j:=0;
if (x>=y) then
b:=x
else
b:=y;
setLength(a,b);
for i:=2 to x do
if (x mod i=0) then begin
j:=j+1; a[j]:=i;
end;
for i:=1 to j do
if (y mod a[i]=0) then begin
common_divisor:=true;
break;
end;
end;
begin
assign(fIn,'fractii.in'); reset(fIn);
assign(fOut,'fractii.out'); rewrite(fOut);
readln(fIn,n);
k:=0;
for i:=1 to n do
for j:=1 to n do
if (i mod j<>0) and (common_divisor(i,j)=false) then
k:=k+1
else if (j=1) then
k:=k+1;
writeln(fOut,k);
close(fIn); close(fOut);
end.