function s = nTermSine5(x,maxterms)
% nTermSine4  Evaluate series approximation to sin(x). Use recursive
%             evaluation of terms, while loop, convergence check and limit
%             maximum number of terms
%
% Synopsis:  s = nTermSine5(x,n)
%
% Input: x = argument of sine(x)
%        maxterms = maximum number of terms in the series
%
% Output: s = approximation to sin(x) with a max of n terms.  Stop when
%             abs(term/sum) < tol, where tol = 5e-6

term = x;  s = term;   %  initialize the sum and the sign of the term
tol = 5e-6;
fprintf('\n    i       term              s\n');
fprintf(' %4d  %18.13f  %8.5f\n',1,term,s);
i = 1;  n=1;
while abs(term/s)>tol && n<maxterms
  i = i + 2;  n = n + 1;
  term = -term*(x^2)/(i*(i-1));
  s = s + term;
  fprintf(' %4d  %18.13f  %8.5f\n',i,term,s)
end