function e = spaghetti ( n )

%*****************************************************************************80
%
%% spaghetti() analyzes the spaghetti problem.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    07 May 2019
%
%  Author:
%
%    Paul Nahin
%
%  Reference:
%
%    Paul Nahin,
%    Will You Be Alive 10 Years From Now?,
%    Princeton, 2014,
%    ISBN: 978-0691156804,
%    LC: QA273.25.N344
%
%  Input:
%
%    integer N, the number of strands of spaghetti.
%
%  Output:
%
%    real E, the expected number of loops created
%    if we begin with N strands of spaghetti and randomly pair the 2*N
%    ends, possibly making loops.
%
  e = 1.0;
  for i = 2 : n
    e = e + 1.0 / ( 2 * i - 1 );
  end

  return
end
