function middle_square_next_test ( )

%*****************************************************************************80
%
%% middle_square_next_test() tests middle_square_next().
%
%  Discussion:
%
%    This function simply demonstrates the results of 10 successive calls
%    to middle_square_next(), for a range of values of d.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 September 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'middle_square_next_test():\n' );
  fprintf ( 1, '  middle_square_next ( s, d ) applies the middle square algorithm\n' )
  fprintf ( 1, '  using a 2*d digit seed.\n' );

  for d = 1 : 5

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Using d = %d\n', d );
    fprintf ( 1, '\n' );

    s = mod ( 2147483647, 10^(2*d) );

    for i = 0 : 10
      fprintf ( 1, '  %2d  %d\n', i, s );
      s = middle_square_next ( s, d );
    end

  end

  return
end

