Pagini recente » Cod sursa (job #2576447) | Cod sursa (job #820829) | Cod sursa (job #1295649) | Cod sursa (job #1489900) | Cod sursa (job #42699)
Cod sursa(job #42699)
var a:array[1..1000000]of integer;
b:array[1..80000]of longint;
n,s,i,j,z,x:longint;
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.