Hailstone numbers

  • Hailstone numbers are the sequence of integers generated by Collatz conjecture\

Example of the use of collatz:

def collatz(i):
    while i > 1:
        print(i, end=' ')
        if (i % 2):
            # i is odd
            i = 3*i + 1
        else:
            # i is even
            i = i//2
    print(1, end='')
 
 
i = int(input('Enter i: '))
print('Sequence: ', end='')
collatz(i)
Sequence: 3 10 5 16 8 4 2 1

Vocabulary

- Collatz: The conjecture asks whether repeating two siple arithmetic operation will transform every positive integer into 1.