# A = 128 CLEAR A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A INCREASE A # C = continue flag CLEAR C INCREASE C # init: I=floor(X/2), R=parity(X) CLEAR R CLEAR I REPEAT X TIMES ( CLEAR T INCREASE T REPEAT R TIMES ( CLEAR T ) CLEAR R REPEAT T TIMES ( INCREASE R ) INCREASE U REPEAT R TIMES ( CLEAR U ) REPEAT U TIMES ( INCREASE I ) CLEAR U CLEAR T ) # Main loop REPEAT A TIMES ( REPEAT C TIMES ( PRINT X # Check if X == 1: I == 0 and R == 1 CLEAR L INCREASE L REPEAT I TIMES ( CLEAR L ) CLEAR M REPEAT L TIMES ( REPEAT R TIMES ( INCREASE M ) ) # Set C = 1 - M CLEAR C INCREASE C REPEAT M TIMES ( CLEAR C ) # Save R to S before processing CLEAR S REPEAT R TIMES ( INCREASE S ) # If even (S==0): X = I CLEAR G INCREASE G REPEAT S TIMES ( CLEAR G ) REPEAT G TIMES ( CLEAR X REPEAT I TIMES ( INCREASE X ) ) # If odd (S==1): X = 3X+1 REPEAT S TIMES ( CLEAR Y REPEAT X TIMES ( INCREASE Y INCREASE Y INCREASE Y ) INCREASE Y CLEAR X REPEAT Y TIMES ( INCREASE X ) CLEAR Y ) # Compute new I = floor(X/2) and R = parity(X) for next iteration CLEAR R CLEAR I REPEAT X TIMES ( CLEAR T INCREASE T REPEAT R TIMES ( CLEAR T ) CLEAR R REPEAT T TIMES ( INCREASE R ) INCREASE U REPEAT R TIMES ( CLEAR U ) REPEAT U TIMES ( INCREASE I ) CLEAR U CLEAR T ) ) )