% Example 9.1a (Physics 330) s=0; % set a variable to zero so that 1/n^2 can be repeatedly added to it N=10000; % set the upper limit of the sum for n=1:N % start of the loop % add 1/n^2 to s each time, then put the answer back into s s=s+1/n^2; end % end of the loop fprintf(' Sum = %g \n',s) % print the answer