function [ n_data, n, m ] = mcnugget_number_values ( n_data )

%*****************************************************************************80
%
%% mcnugget_number_values() returns McNugget numbers.
%
%  Discussion:
%
%    A restaurant offers Chicken McNuggets, but only in packages of 6, 9 or 20.
%
%    A customer wishes to buy exactly N McNuggets.
%
%    Presumably, there are M distinct ways to do this.  M is known as the
%    McNugget number of N.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 September 2022
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Scott Chapman, Chris O’Neill,
%    Factoring in the Chicken McNugget Monoid,
%    Mathematics Magazine, 
%    Volume 91, Number 5, 2018, pages 323-336.
%
%  Input:
%
%    integer N_DATA.  The user sets N_DATA to 0 before the first call.  
%    Thereafter, it should simply be the value returned by the previous call.
%
%  Output:
%
%    integer N_DATA.  On each call, the routine increments N_DATA by 1, and
%    returns the corresponding data; when there is no more data, the
%    output value of N_DATA will be 0 again.
%
%    integer N: the number of McNuggets desired.
%
%    integer M: the number of different ways of getting N McNuggets.
%
  n_max = 101;

  n_vec = [ ...
     0,  1,  2,  3,  4,  5,  6,  7,  8,  9, ...
    10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...
    20, 21, 22, 23, 24, 25, 26, 27, 28, 29, ...
    30, 31, 32, 33, 34, 35, 36, 37, 38, 39, ...
    40, 41, 42, 43, 44, 45, 46, 47, 48, 49, ...
    50, 51, 52, 53, 54, 55, 56, 57, 58, 59, ...
    60, 61, 62, 63, 64, 65, 66, 67, 68, 69, ...
    70, 71, 72, 73, 74, 75, 76, 77, 78, 79, ...
    80, 81, 82, 83, 84, 85, 86, 87, 88, 89, ...
    90, 91, 92, 93, 94, 95, 96, 97, 98, 99, ...
   100 ...
  ];

  m_vec = [ ...
    1,  0,  0,  0,  0,  0,  1,  0,  0,  1, ...
    0,  0,  1,  0,  0,  1,  0,  0,  2,  0, ...
    1,  1,  0,  0,  2,  0,  1,  2,  0,  1, ...
    2,  0,  1,  2,  0,  1,  3,  0,  2,  2, ...
    1,  1,  3,  0,  2,  3,  1,  2,  3,  1, ...
    2,  3,  1,  2,  4,  1,  3,  3,  2,  2, ...
    5,  1,  3,  4,  2,  3,  5,  2,  3,  5, ...
    2,  3,  6,  2,  4,  5,  3,  3,  7,  2, ...
    5,  6,  3,  4,  7,  3,  5,  7,  3,  5, ...
    8,  3,  6,  7,  4,  5,  9,  3,  7,  8, ...
    5 ...
  ];

  if ( n_data < 0 )
    n_data = 0;
  end

  n_data = n_data + 1;

  if ( n_max < n_data )
    n_data = 0;
    n = 0;
    m = 0;
  else
    n = n_vec(n_data);
    m = m_vec(n_data);
  end

  return
end
