Pagini recente » Cod sursa (job #2057657) | Cod sursa (job #2303989) | Cod sursa (job #1110828) | Cod sursa (job #1432259) | Cod sursa (job #743560)
Cod sursa(job #743560)
program fractr;
var p:array[1..1000000] of boolean;
n,i,j,max,min:longint;
s:qword;
function cmmdc(a,b:longint):longint;
begin
if a mod b=0 then cmmdc:=b
else cmmdc:=cmmdc(b,a mod b);
end;
procedure ciur(n:longint);
var i,j:longint;
begin
p[2]:=true;
for i:=2 to n div 2 do
begin
j:=i+i;
while j<=n do begin p[j]:=true; j:=j+i end;
end;
end;
begin
assign(input,'fractii.in'); reset(input);
assign(output,'fractii.out'); rewrite(output);
read(n);
close(input);
ciur(n);
s:=n;
for i:=2 to n do
for j:=1 to n do
if j mod i<>0 then
if (not p[i])and(not p[j]) then s:=s+1
else begin
if i>j then begin max:=i; min:=j end
else begin max:=j; min:=i end;
if cmmdc(max,min)=1 then s:=s+1;
end;
write(s);
close(output);
end.