# 814900 commands with 1000 as starting number # Used to detect when to stop loop INCREASE L # Create a big number (180) to loop many times (number 871 takes the most steps: 178) INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q INCREASE Q # Print the initial value PRINT X # Stop if X is 1 initially REPEAT X TIMES ( CLEAR L REPEAT D TIMES ( INCREASE L CLEAR D ) INCREASE D ) # Start the main loop REPEAT Q TIMES ( REPEAT L TIMES ( # Clear variables before re-use CLEAR B CLEAR O CLEAR T CLEAR C CLEAR V CLEAR Y # These needs to be 1 for the odd-even loop to work INCREASE T INCREASE O # Check if X is odd or even, and save the halved value of X in V REPEAT X TIMES ( INCREASE B REPEAT T TIMES ( CLEAR B CLEAR T ) REPEAT B TIMES ( INCREASE V INCREASE T ) ) # This only runs if X was even because in that case T is 1 instead of 0 REPEAT T TIMES ( # If X was even, set X to the halved value stored in V REPEAT T TIMES ( CLEAR X REPEAT V TIMES ( INCREASE X ) ) # If X was even, dont run the odd-loop CLEAR O ) # Run only if even-loop wasn't ran REPEAT O TIMES ( # Multiply X by 3 and add 1 REPEAT X TIMES ( INCREASE X INCREASE X ) INCREASE X ) # Print the resulting value PRINT X # Stop if X is 1 REPEAT T TIMES ( REPEAT X TIMES ( CLEAR L REPEAT C TIMES ( INCREASE L CLEAR C ) INCREASE C ) ) ) )