def Collatz(x):
yield x
while(x!=1):
if(x & 1 == 1):
x = x*3+1
yield x
else:
x = x >> 1
yield x
for x in Collatz(13): print x
ZGVmIENvbGxhdHooeCk6CiAgICB5aWVsZCB4CiAgICB3aGlsZSh4IT0xKToKICAgICAgICBpZih4ICYgMSA9PSAxKToKICAgICAgICAgICAgeCA9IHgqMysxCiAgICAgICAgICAgIHlpZWxkIHgKICAgICAgICBlbHNlOgogICAgICAgICAgICB4ID0geCA+PiAxCiAgICAgICAgICAgIHlpZWxkIHgKCmZvciB4IGluIENvbGxhdHooMTMpOiBwcmludCB4