function steve ( k )

%*****************************************************************************80
%
%% STEVE: Steve's elevator problem.
%
%  Discussion:
%
%    Steve gets on an elevator going up.  There are 11 higher floors.
%    Steve wishes to go up 9 floors.
%    There are K additional riders in the elevator, each of whom has
%    randomly chosen one of the 11 higher floors as destination.
%    On average, how many times will the elevator stop until Steve
%    reaches his floor?
%
%  Modified:
%
%    23 January 2018
%
%  Author:
%
%    Paul Nahin
%
%  Reference:
%
%    Paul Nahin,
%    Digital Dice: Computational Solutions to Practical Probability Problems,
%    Princeton, 2008,
%    ISBN: 978-0-691-15821-1.
%
%  Parameters:
%
%    Input, integer K, the number of elevator riders in addition to Steve.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'STEVE:\n' );
  fprintf ( 1, '  Steve gets on an elevator going up.  There are 11 higher floors.\n' );
  fprintf ( 1, '  Steve wishes to go up 9 floors.\n' );
  fprintf ( 1, '  There are K additional riders in the elevator, each of whom has\n' );
  fprintf ( 1, '  randomly chosen one of the 11 higher floors as destination.\n' );
  fprintf ( 1, '  On average, how many times will the elevator stop until Steve\n' );
  fprintf ( 1, '  reaches his floor?\n' );

  S = 0;

  for loop = 1 : 1000000

    x = zeros ( 1, 11 );
    x(9) = 1;
    for j = 1 : k
      rider = floor ( 11 * rand ) + 1;
      x(rider) = 1;
    end

    stops = 1;
    for j = 1 : 8
      stops = stops + x(j);
    end

    S = S + stops;

  end

  S = S / 1000000;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Estimated number of stops = %g\n', S );
  fprintf ( 1, '  Theoretical number is %g\n', 9 - 8 * ( 10/11 ) ^ k );

  return
end
