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 PRINT X # C = continue flag CLEAR C INCREASE C REPEAT A TIMES ( REPEAT C TIMES ( # Save original X for odd case CLEAR Y REPEAT X TIMES ( INCREASE Y ) # Compute I = floor(X/2) and R = parity(X) together in one loop CLEAR R CLEAR I REPEAT X TIMES ( CLEAR T INCREASE T REPEAT R TIMES ( CLEAR T ) CLEAR R REPEAT T TIMES ( INCREASE R ) CLEAR U INCREASE U REPEAT R TIMES ( CLEAR U ) REPEAT U TIMES ( INCREASE I ) ) # Check if I == 0 (which means X == 1), if so set C = 0 and skip processing CLEAR L INCREASE L REPEAT I TIMES ( CLEAR L ) # L == 1 if I == 0 (X == 1), L == 0 if I != 0 (X > 1) REPEAT L TIMES ( CLEAR C ) # G = 1 if we should process (L == 0), G = 0 if we should skip (L == 1) CLEAR G INCREASE G REPEAT L TIMES ( CLEAR G ) REPEAT G TIMES ( # If X is even (R == 0): X = I = floor(X/2) CLEAR H INCREASE H REPEAT R TIMES ( CLEAR H ) REPEAT H TIMES ( CLEAR X REPEAT I TIMES ( INCREASE X ) PRINT X ) # If X is odd (R == 1): X = Y * 3 + 1 (using saved original X) REPEAT R TIMES ( CLEAR X REPEAT Y TIMES ( INCREASE X INCREASE X INCREASE X ) INCREASE X PRINT X ) ) ) )