function count = hail_count ( n )

  count = 0;
   
  while ( n ~= 1 )
  
    if ( mod ( n, 2 ) == 0 )
      n = n / 2;
    else
      n = 3 * n + 1;
    end
    
    count = count + 1;
    
  end
  
  return
end

