# This program implements the hailstone sequence # as a procedural algorithm. # Returns a list of all integers in a hailstone # sequence starting with n until n reaches 1. def hailstone_sequence(n): result = [n] while n != 1: if n % 2 == 0: n = n // 2 else: n = 3 * n + 1 result.append(n) return result def main(): n = int(input("Value of N? ")) values = hailstone_sequence(n) print("Hailstone sequence starting with", n, ":") for k in values: print(k, end=" ") print() main()