def odd_generator(limit):
    """ An odd number generator """
    current = 1
    while current < limit:
        yield current
        current = current + 2

def infinite_odd_generator():

    """ An infinite odd number generator """
    current = 1
    while True:
        yield current
        current = current + 2

def get_code(file):

    """

    filter out comment lines that start with # from the given file

    yield one non comment line at a time

    """

    for line in file:

        if not line.strip().startswith('#'):

            yield line


def mystery(text):
    current = len(text) -1
    while current >= 0:
        yield text[current]
        current = current - 1


def hailstone(number):
    current = number
    while current > 1:
        yield current
        if current % 2 == 0:  # % is the modulo operator.  It is used to check if current is even
            current = current / 2
        else:    #  if current is odd
            current = 3 * current + 1
    yield current


def main():
    for i in hailstone(5):
        print (int(i), end=' ')

if __name__ == '__main__':
    main()