% script logsum1.m % Slowly convergent log series % Evaluate partial sums n = input('Enter number of terms '); % The loop calculates each term from the preceding term % and adds it onto the partial sum. t = 1.0; % first term s = t; % first partial sum fprintf('%5d %20.10e %20.10e\n',1,t,s); for k = 2 : n t = -((k-1)/k)*t; s = s + t; fprintf('%5d %20.10e %20.10e\n',k,t,s); end