function [ n_data, n ] = mersenne_prime_values ( n_data )

%*****************************************************************************80
%
%% mersenne_prime_values() returns some indices of Mersenne primes.
%
%  Discussion:
%
%    A Mersenne number Mn = 2^n-1.
%    A Mersenne prime is a prime Mersenne number.
%    If Mn is a Mersenne prime, then the index n must also be prime.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 October 2024
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer n_data: the user sets N_data to 0 before the first 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 index of a Mersenne prime.
%
  n_max = 52;

  n_vec = [ ...
           2,         3,         5,         7,        13, ...
          17,        19,        31,        61,        89, ...
         107,       127,       521,       607,      1279, ...
        2203,      2281,      3217,      4253,      4423, ...
        9689,      9941,     11213,     19937,     21701, ...
       23209,     44497,     86243,    110503,    132049, ...
      216091,    756839,    859433,   1257787,   1398269, ...
     2976221,   3021377,   6972593,  13466917,  20996011, ...
    24036583,  25964951,  30402457,  32582657,  37156667, ...
    42643801,  43112609,  57885161,  74207281,  77232917, ...
    82589933, 136279841 ];

  if ( n_data < 0 )
    n_data = 0;
  end

  n_data = n_data + 1;

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

  return
end
