function lset = collatz_level ( k )

%*****************************************************************************80
%
%% collatz_level() returns the nodes at distance k from 1.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 June 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer L: the desired level.
%
%  Output:
%
%    integer LSET(*): the points at level L.
%
  lset = zeros ( 1, 1 );
  lset(1) = 1;

  for level = 1 : k

    lset = collatz_inverse ( lset );
    
  end

  lset = sort ( lset );

  return
end

