Posted on 9th May 2025|25 views
Can anyone give an example python program to test Collatz Conjecture for a given number?
Posted on 9th May 2025| views
Here is the example.
def collatz(x):
while x > 1:
print(x, end=' ')
if (x % 2):
x = 3*x + 1
else:
x = x//2
print(1, end='')
x = int(input('Enter x: '))
print('Sequence: ', end='')
collatz(x)