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