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 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 # A = 179 is the length of the Maximum collatz sequence (X=871) REPEAT A TIMES ( # Basically a WHILE TRUE # Check to terminate CLEAR B CLEAR C REPEAT X TIMES ( CLEAR D INCREASE D REPEAT C TIMES ( CLEAR D INCREASE B ) CLEAR C REPEAT D TIMES ( INCREASE C ) ) CLEAR D INCREASE D REPEAT B TIMES ( CLEAR D ) CLEAR E INCREASE E REPEAT D TIMES ( CLEAR E ) # B := HALF X # C := MOD2 X # D := ISZERO HALF X # E := NOT ISZERO HALF X REPEAT E TIMES ( # If we do not terminate PRINT X REPEAT C TIMES ( # If X is odd, Multiply by 3 and add 1. CLEAR F REPEAT X TIMES ( INCREASE F ) REPEAT X TIMES ( INCREASE F ) REPEAT X TIMES ( INCREASE F ) INCREASE F PRINT F # F = 3X+1 REPEAT B TIMES ( INCREASE X ) INCREASE X ) CLEAR D INCREASE D # Otherwise it is even. REPEAT C TIMES ( CLEAR D ) # D = NOT C REPEAT D TIMES ( # Otherwise X is even. Divide by 2. CLEAR X REPEAT B TIMES ( INCREASE X ) ) ) ) PRINT X