function hail3 ( n )

%% HAIL3 does a single check for even/not1 and odd/not1 numbers.

  tic

  x = linspace ( 1, n, n );
  y = x;
  z = zeros ( n, 1 );

  while ( any ( y ~= 1 ) )

    i1 = find ( y ~= 1 && mod ( y, 2 ) == 0 );
    i2 = find ( y ~= 1 && mod ( y, 2 ) == 1 );

    z(i1) = z(i1) + 1;
    z(i2) = z(i2) + 1;

    y(i1) = y(i1) / 2;
    y(i2) = 3 * y(i2) + 1; 

  end

  figure ( 3 )
  plot ( x, z, 'b*' )
  title ( 'HAIL3' )

  toc

  return
end
