def hail(n):

print(n, end=” “)

if n == 1:

return

if n%2 == 0:

hail(n//2)

else:

hail(3*n+1)

hail(7)

print()

hail(8)

# Output

7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1

8 4 2 1

def hail(n):

print(n, end=” “)

if n == 1:

return

if n%2 == 0:

hail(n//2)

else:

hail(3*n+1)

hail(7)

print()

hail(8)

# Output

7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1

8 4 2 1