Pagini recente » Cod sursa (job #1923300) | Cod sursa (job #2508607) | Cod sursa (job #530988) | Cod sursa (job #3181984) | Cod sursa (job #108471)
Cod sursa(job #108471)
var a:array[1..1000000]of integer;
b:array[1..80000]of longint;
n,i,j,z,x,y: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
x:=n-n div b[i];
s:=s+x;
s:=s+(x-z+1);
end;
s:=s+(n-z)*2-1;
writeln(s);
close(output);
end.