prompt N
N→M: 0→X: 1→L
While L=1
X+1→X
Disp M
If M=1
Then: 0→L
Else
If remainder(M,2)=1
Then: 3*M+1→M
Else: M/2→M
End
{N,X}