Lời giải :
program hotrotinhoc;
var i,n : integer;
T,S : real ;
begin
write('Nhap n='); readln(n);
while (n>1) or (n>2018) do
begin
write('n chua thoa man yeu cau nhap lai n='); readln(n);
end;
for i:= 1 to n do
S:=S+1/((i-1)+i) ;
T:=S+2018;
write('S=',S);
readln
end.