Pagini recente » Cod sursa (job #1238784) | Cod sursa (job #1332741) | Cod sursa (job #390740) | Cod sursa (job #931641) | Cod sursa (job #42748)
Cod sursa(job #42748)
var a:array[1..1000000]of integer;
b:array[1..80000]of longint;
n,i,j,z,x:longint;
s:int64;
begin
assign(input,'fractii.in');
reset(input);
assign(output,'fractii.out');
rewrite(output);
readln(n);
for i:=2 to n do
begin
if a[i]=0 then
begin
z:=z+1;
b[z]:=i;
end;
j:=i;
if a[i]=0 then
while j<=n do
begin
j:=j+i;
if j>n then break;
a[j]:=1;
end;
end;
if n=2 then s:=2;
for i:=1 to z do
begin
if b[i]<=n div 2 then s:=s+n div b[i]-1;
x:=n-n div b[i];
s:=s+x;
s:=s+(x-z+1);
end;
s:=s+(n-z)*2-1;
s:=s-1;
writeln(s);
close(output);
end.